aboutsummaryrefslogtreecommitdiffstats
path: root/web/api/public/switch-state
diff options
context:
space:
mode:
authorOle Mathias Aa. Heggem <msbone1995@gmail.com>2018-03-21 13:27:46 +0100
committerGitHub <noreply@github.com>2018-03-21 13:27:46 +0100
commit2b3beb9f93fc6486169e47f96995a97dd64baf2a (patch)
tree7151c023924254d863387f484829b503759359ea /web/api/public/switch-state
parent8f1eeeabe7b33d224ed9a8e19cc16825c144a0f6 (diff)
parent5abf053bac220b49539104bfa63805fd0829ca45 (diff)
Merge branch 'master' into network-firstclass
Diffstat (limited to 'web/api/public/switch-state')
-rwxr-xr-xweb/api/public/switch-state9
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();
+