aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/ping-json.pl
diff options
context:
space:
mode:
Diffstat (limited to 'web/nms.gathering.org/ping-json.pl')
-rwxr-xr-xweb/nms.gathering.org/ping-json.pl10
1 files changed, 9 insertions, 1 deletions
diff --git a/web/nms.gathering.org/ping-json.pl b/web/nms.gathering.org/ping-json.pl
index 47b5cc2..78e795a 100755
--- a/web/nms.gathering.org/ping-json.pl
+++ b/web/nms.gathering.org/ping-json.pl
@@ -13,7 +13,15 @@ $q->execute();
my %json = ();
while (my $ref = $q->fetchrow_hashref()) {
- $json{$ref->{'switch'}} = $ref->{'latency_ms'};
+ $json{'switches'}{$ref->{'switch'}} = $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;");
+$lq->execute();
+while (my $ref = $lq->fetchrow_hashref()) {
+ $json{'linknets'}{$ref->{'linknet'}} = [ $ref->{'latency1_ms'}, $ref->{'latency2_ms'} ];
+}
+
+$q->execute();
print $cgi->header(-type=>'text/json; charset=utf-8');
print JSON::XS::encode_json(\%json);