diff options
author | Kristian Lyngstøl <kly@kly.no> | 2018-03-21 10:43:33 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-21 10:43:33 +0100 |
commit | 4eaeb1d7dc6095a2eec1b4711de94f907654547e (patch) | |
tree | 5b4b00409761f44227b9294e0c62f059ab68fae9 /web/api/public/switch-state | |
parent | 0016b6612e79cc5b115aae11c7f37ec2a27420e1 (diff) | |
parent | dfc74df8f82d7c295319f3e197cb2d37a8ee6ddd (diff) |
Merge pull request #167 from olemathias/master
Varnish is now installed in the ansible install + chart colors
Diffstat (limited to 'web/api/public/switch-state')
-rwxr-xr-x | web/api/public/switch-state | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/web/api/public/switch-state b/web/api/public/switch-state index 77350c7..965e881 100755 --- a/web/api/public/switch-state +++ b/web/api/public/switch-state @@ -14,9 +14,9 @@ my ($switch, $port) = split(/\//,$target,2); my $q; if (!defined($switch)) { - $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch);'); + $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . ' and switches.deleted = false group by switch);'); } else { - $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch) and sysname = ' . $nms::web::dbh->quote($switch) . ';'); + $q = $nms::web::dbh->prepare('select sysname,extract(epoch from date_trunc(\'second\',time)) as time,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch) and sysname = ' . $nms::web::dbh->quote($switch) . ' and switches.deleted = false;'); } $q->execute(); @@ -24,7 +24,7 @@ while ( my $ref = $q->fetchrow_hashref() ) { my $sysname = $ref->{'sysname'}; my %data = %{JSON::XS::decode_json($ref->{'data'})}; - + $json{'switches'}{$sysname}{'clients'}{'live'} = 0; $json{'then'}{$sysname}{'clients'}{'live'} = 0; for my $porti (keys %{$data{'ports'}}) { @@ -93,7 +93,7 @@ while ( my $ref = $q2->fetchrow_hashref() ) { my $sysname = $ref->{'sysname'}; my %data = %{JSON::XS::decode_json($ref->{'data'})}; - + for my $porti (keys %{$data{'ports'}}) { if (defined($port) and $port ne "" and $port ne $porti) { next; @@ -149,3 +149,4 @@ while ( my $ref = $q2->fetchrow_hashref() ) { $nms::web::cc{'max-age'} = "5"; $nms::web::cc{'stale-while-revalidate'} = "30"; finalize_output(); + |