aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/port-state.pl
diff options
context:
space:
mode:
Diffstat (limited to 'web/nms.gathering.org/port-state.pl')
-rwxr-xr-xweb/nms.gathering.org/port-state.pl16
1 files changed, 13 insertions, 3 deletions
diff --git a/web/nms.gathering.org/port-state.pl b/web/nms.gathering.org/port-state.pl
index 76dd7d8..83e15f1 100755
--- a/web/nms.gathering.org/port-state.pl
+++ b/web/nms.gathering.org/port-state.pl
@@ -21,7 +21,7 @@ my $when =" time > " . $now . " - '5m'::interval and time < " . $now . " ";
my %json = ();
if (defined($cin)) {
- $when = " time < " . $now . " - '$cin'::interval and time > ". $now . " - ('$cin'::interval + '15m'::interval) ";
+ $when = " time < " . $now . " - '$cin'::interval and time > ". $now . " - ('$cin'::interval + '5m'::interval) ";
}
my $query = 'select sysname,extract(epoch from date_trunc(\'second\',time)) as time, ifname,ifhighspeed,ifhcinoctets,ifhcoutoctets from polls natural join switches where time in (select max(time) from polls where ' . $when . ' group by switch,ifname);';
@@ -37,7 +37,7 @@ while (my $ref = $q->fetchrow_hashref()) {
}
#print Dumper(%json);
-my $q2 = $dbh->prepare('select switch,sysname,placement,zorder,ip,switchtype,poll_frequency,community,last_updated from switches natural join placements');
+my $q2 = $dbh->prepare('select switch,sysname,placement,ip,switchtype,poll_frequency,community,last_updated from switches natural join placements');
my $q3 = $dbh->prepare('select distinct on (switch) switch,temp,time,sysname from switch_temp natural join switches where ' . $when . ' order by switch,time desc');
$q2->execute();
@@ -54,7 +54,6 @@ while (my $ref = $q2->fetchrow_hashref()) {
$json{'switches'}{$ref->{'sysname'}}{'placement'}{'y'} = $y2;
$json{'switches'}{$ref->{'sysname'}}{'placement'}{'width'} = $x1 - $x2;
$json{'switches'}{$ref->{'sysname'}}{'placement'}{'height'} = $y1 - $y2;
- $json{'switches'}{$ref->{'sysname'}}{'placement'}{'zorder'} = $ref->{'zorder'};
}
$q3->execute();
while (my $ref = $q3->fetchrow_hashref()) {
@@ -70,5 +69,16 @@ while (my $ref = $q4->fetchrow_hashref()) {
# push @{$json{'linknets'}}, $ref;
}
+my $q5 = $dbh->prepare ('select ' . $now . ' as time;');
+$q5->execute();
+$json{'time'} = $q5->fetchrow_hashref()->{'time'};
+
+my $q6 = $dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,state,username,id,comment from switch_comments natural join switches order by time desc');
+$q6->execute();
+while (my $ref = $q6->fetchrow_hashref()) {
+ push @{$json{'switches'}{$ref->{'sysname'}}{'comments'}},$ref;
+}
+
+$json{'username'} = $cgi->remote_user();
print $cgi->header(-type=>'text/json; charset=utf-8');
print JSON::XS::encode_json(\%json);