diff options
Diffstat (limited to 'web/api/public/dhcp')
-rwxr-xr-x | web/api/public/dhcp | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/web/api/public/dhcp b/web/api/public/dhcp deleted file mode 100755 index 3e56f59..0000000 --- a/web/api/public/dhcp +++ /dev/null @@ -1,36 +0,0 @@ -#! /usr/bin/perl -# vim:ts=8:sw=8 - -use lib '/opt/gondul/include'; -use nms::web qw (%json finalize_output); -use strict; -use warnings; -use Data::Dumper; - -nms::web::setwhen('60m'); -#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;'); -my $q_v4 = $nms::web::dbh->prepare("select distinct on (name) extract(epoch from date_trunc('second', metrics.time)) as time, networks.name as name from metrics JOIN networks ON (data->>'clientip')::inet <<= networks.subnet4 where $nms::web::when order by name,time desc;"); -$q_v4->execute(); -while ( my $ref = $q_v4->fetchrow_hashref() ) { - my $sysname = $ref->{'sname'}; - $json{'dhcp4'}{$ref->{'name'}} = $ref->{'time'}; -} - -my $q_v6 = $nms::web::dbh->prepare("select distinct on (name) extract(epoch from date_trunc('second', metrics.time)) as time, networks.name as name from metrics JOIN networks ON (data->>'clientip')::inet <<= networks.subnet6 where $nms::web::when order by name,time desc;"); -$q_v6->execute(); -while ( my $ref = $q_v6->fetchrow_hashref() ) { - my $sysname = $ref->{'sname'}; - $json{'dhcp6'}{$ref->{'name'}} = $ref->{'time'}; -} - - -#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;"); -my $q2 = $nms::web::dbh->prepare("SELECT networks.name, count(distinct data->>'clientmac') as clients, count(distinct data->>'clientip') as addresses, count(data->>'clientmac') as acks from metrics JOIN networks ON (data->>'clientip')::inet <<= networks.subnet4 WHERE $nms::web::when GROUP BY networks.name;"); -$q2->execute(); -while (my $ref = $q2->fetchrow_hashref()) { - $nms::web::json{'networks'}{$ref->{name}} = $ref; -} - -$nms::web::cc{'max-age'} = "10"; -$nms::web::cc{'stale-while-revalidate'} = "30"; -finalize_output(); |