aboutsummaryrefslogtreecommitdiffstats
path: root/web/api/public
diff options
context:
space:
mode:
Diffstat (limited to 'web/api/public')
-rwxr-xr-xweb/api/public/dhcp10
-rwxr-xr-xweb/api/public/switch-state8
2 files changed, 9 insertions, 9 deletions
diff --git a/web/api/public/dhcp b/web/api/public/dhcp
index 0b0bb49..f153a49 100755
--- a/web/api/public/dhcp
+++ b/web/api/public/dhcp
@@ -8,16 +8,16 @@ use warnings;
use Data::Dumper;
nms::web::setwhen('60m');
-my $q = $nms::web::dbh->prepare('select distinct on (sysname) extract(epoch from date_trunc(\'second\',time)) as time,sysname from dhcp join switches on dhcp.switch = switches.switch where ' . $nms::web::when . ' and switches.deleted = false order by sysname,time desc;');
+my $q = $nms::web::dbh->prepare('select distinct on (name) extract(epoch from date_trunc(\'second\',time)) as time,name from dhcp join networks on dhcp.network = networks.network where ' . $nms::web::when . ' order by name,time desc;');
$q->execute();
while ( my $ref = $q->fetchrow_hashref() ) {
- my $sysname = $ref->{'sysname'};
- $json{'dhcp'}{$ref->{'sysname'}} = $ref->{'time'};
+ my $sysname = $ref->{'sname'};
+ $json{'dhcp'}{$ref->{'name'}} = $ref->{'time'};
}
-my $q2 = $nms::web::dbh->prepare("select sysname,count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp natural join switches where $nms::web::when and switches.deleted = false group by switches.sysname;");
+my $q2 = $nms::web::dbh->prepare("select name,count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp natural join networks where $nms::web::when group by networks.name;");
$q2->execute();
while (my $ref = $q2->fetchrow_hashref()) {
- $nms::web::json{'switches'}{$ref->{sysname}} = $ref;
+ $nms::web::json{'networks'}{$ref->{name}} = $ref;
}
$nms::web::cc{'max-age'} = "10";
diff --git a/web/api/public/switch-state b/web/api/public/switch-state
index 965e881..19bd771 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 . ' and switches.deleted = false 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) and switches.deleted = false and not switches.tags \?& array[\'switchstateignore\'];');
} 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) . ' and switches.deleted = false;');
+ $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 and not switches.tags \?& array[\'switchstateignore\'];');
}
$q->execute();
@@ -83,9 +83,9 @@ while ( my $ref = $q->fetchrow_hashref() ) {
nms::web::setwhen('15m','10m');
my $q2;
if (!defined($switch)) {
- $q2 = $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);');
+ $q2 = $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) and switches.deleted = false and not switches.tags \?& array[\'switchstateignore\'];');
} else {
- $q2 = $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) . ';');
+ $q2 = $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 and not switches.tags \?& array[\'switchstateignore\'];');
}
$q2->execute();