aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/switches-json.pl
diff options
context:
space:
mode:
authorroot <root@frank.tg14.gathering.org>2014-04-15 18:43:53 +0200
committerroot <root@frank.tg14.gathering.org>2014-04-15 18:43:53 +0200
commitf2a6303dd8105475fcea676bead10f52df36f639 (patch)
tree3e2bccd1508f7272b2758bb3af6bbc93da0d5a0b /web/nms.gathering.org/switches-json.pl
parent92d3c54dcba00a7700a7735a202b0d7eca1ccfbf (diff)
Ping linknets, and show that on the map.
Diffstat (limited to 'web/nms.gathering.org/switches-json.pl')
-rwxr-xr-xweb/nms.gathering.org/switches-json.pl12
1 files changed, 9 insertions, 3 deletions
diff --git a/web/nms.gathering.org/switches-json.pl b/web/nms.gathering.org/switches-json.pl
index 67017b4..2ccb247 100755
--- a/web/nms.gathering.org/switches-json.pl
+++ b/web/nms.gathering.org/switches-json.pl
@@ -8,17 +8,16 @@ use nms;
my $cgi = CGI->new;
my $dbh = nms::db_connect();
+my %json = ();
my $q = $dbh->prepare('select switch,sysname,placement,zorder from switches natural join placements');
$q->execute();
-
-my %json = ();
while (my $ref = $q->fetchrow_hashref()) {
$ref->{'placement'} =~ /\((-?\d+),(-?\d+)\),\((-?\d+),(-?\d+)\)/;
my ($x1, $y1, $x2, $y2) = ($1, $2, $3, $4);
my $sysname = $ref->{'sysname'};
$sysname =~ s/\..*$//;
- $json{$ref->{'switch'}} = {
+ $json{'switches'}{$ref->{'switch'}} = {
sysname => $sysname,
x => $x2,
y => $y2,
@@ -27,5 +26,12 @@ while (my $ref = $q->fetchrow_hashref()) {
zorder => $ref->{'zorder'}
};
}
+
+my $q = $dbh->prepare('select linknet,switch1,switch2 from linknets');
+$q->execute();
+while (my $ref = $q->fetchrow_hashref()) {
+ push @{$json{'linknets'}}, $ref;
+}
+
print $cgi->header(-type=>'text/json; charset=utf-8');
print JSON::XS::encode_json(\%json);