diff options
author | Kristian Lyngstol <kristian@bohemians.org> | 2015-04-03 16:08:25 +0200 |
---|---|---|
committer | Kristian Lyngstol <kristian@bohemians.org> | 2015-04-03 16:08:25 +0200 |
commit | f496d5413912e461eb7a4deb34e2f770310e37d4 (patch) | |
tree | 0b03daa8426430b8b106f8cd1c97b227582ea56c | |
parent | 66b73c6c478609da19dd2f11b3976c439b3780b1 (diff) |
switches-json2.pl is merged with port-state
-rwxr-xr-x | web/nms.gathering.org/switches-json2.pl | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/web/nms.gathering.org/switches-json2.pl b/web/nms.gathering.org/switches-json2.pl deleted file mode 100755 index e63a90e..0000000 --- a/web/nms.gathering.org/switches-json2.pl +++ /dev/null @@ -1,43 +0,0 @@ -#! /usr/bin/perl -use CGI; -use GD; -use DBI; -use JSON::XS; -use lib '../../include'; -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'); -my $q2 = $dbh->prepare('select distinct on (switch) switch,temp,time,sysname from switch_temp natural join switches order by switch,time desc'); - -$q->execute(); -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'}; - $json{'switches'}{$ref->{'sysname'}} = { - x => $x2, - y => $y2, - width => $x1 - $x2, - height => $y1 - $y2, - zorder => $ref->{'zorder'} - }; -} -$q2->execute(); -while (my $ref = $q2->fetchrow_hashref()) { - my $sysname = $ref->{'sysname'}; - $json{'switches'}{$ref->{'sysname'}}{'temp'} = $ref->{'temp'}; - $json{'switches'}{$ref->{'sysname'}}{'time'} = $ref->{'time'}; -} - -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); |