From f8ac8c0b67d306319bcb404f49b4f0e7feb9d510 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 16 Apr 2014 16:35:25 +0200 Subject: Support pinging secondary loopbacks. --- web/nms.gathering.org/ping-json.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'web/nms.gathering.org/ping-json.pl') diff --git a/web/nms.gathering.org/ping-json.pl b/web/nms.gathering.org/ping-json.pl index 78e795a..e661e8f 100755 --- a/web/nms.gathering.org/ping-json.pl +++ b/web/nms.gathering.org/ping-json.pl @@ -7,13 +7,18 @@ use nms; my $cgi = CGI->new; my $dbh = nms::db_connect(); +my %json = (); my $q = $dbh->prepare("SELECT DISTINCT ON (switch) switch, latency_ms FROM ping WHERE updated >= NOW() - INTERVAL '15 secs' ORDER BY switch, updated DESC;"); $q->execute(); - -my %json = (); while (my $ref = $q->fetchrow_hashref()) { - $json{'switches'}{$ref->{'switch'}} = $ref->{'latency_ms'}; + $json{'switches'}{$ref->{'switch'}}{'latency'} = $ref->{'latency_ms'}; +} + +my $qs = $dbh->prepare("SELECT DISTINCT ON (switch) switch, latency_ms FROM ping_secondary_ip WHERE updated >= NOW() - INTERVAL '15 secs' ORDER BY switch, updated DESC;"); +$qs->execute(); +while (my $ref = $qs->fetchrow_hashref()) { + $json{'switches'}{$ref->{'switch'}}{'latency_secondary'} = $ref->{'latency_ms'}; } my $lq = $dbh->prepare("SELECT DISTINCT ON (linknet) linknet, latency1_ms, latency2_ms FROM linknet_ping WHERE updated >= NOW() - INTERVAL '15 secs' ORDER BY linknet, updated DESC;"); -- cgit v1.2.3