From be54730288b9925003e88788e65f11199cc8292b Mon Sep 17 00:00:00 2001 From: root Date: Mon, 26 Mar 2018 13:04:05 +0200 Subject: =?UTF-8?q?Mange=20dager=20med=20rot=20p=C3=A5=20TG18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web/api/public/dhcp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'web/api/public/dhcp') 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"; -- cgit v1.2.3