diff options
Diffstat (limited to 'web/api/public/dhcp')
-rwxr-xr-x | web/api/public/dhcp | 10 |
1 files changed, 5 insertions, 5 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"; |