From 727e4ab31aa6d1a754711d4cd29dbcefae2e952a Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 21 Mar 2016 20:11:55 +0100 Subject: NMS: NMS Public --- .../api/public/dhcp-summary | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 web/nms-public.gathering.org/api/public/dhcp-summary (limited to 'web/nms-public.gathering.org/api/public/dhcp-summary') diff --git a/web/nms-public.gathering.org/api/public/dhcp-summary b/web/nms-public.gathering.org/api/public/dhcp-summary new file mode 100755 index 0000000..dd643b2 --- /dev/null +++ b/web/nms-public.gathering.org/api/public/dhcp-summary @@ -0,0 +1,21 @@ +#! /usr/bin/perl +use lib '../../../../include'; +use strict; +use warnings; +use nms::web; + +nms::web::setwhen('2h'); +my $q = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp;"); +$q->execute(); +while (my $ref = $q->fetchrow_hashref()) { + $nms::web::json{'dhcp'}{'total'} = $ref; +} + +my $q2 = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp where $nms::web::when;"); +$q2->execute(); +while (my $ref = $q2->fetchrow_hashref()) { + $nms::web::json{'dhcp'}{'recent'} = $ref; +} +$nms::web::cc{'max-age'} = "10"; +$nms::web::cc{'stale-while-revalidate'} = "15"; +finalize_output(); -- cgit v1.2.3 From 004f4efcfd0779f4307b90fed139dc87d01ad0b9 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sat, 26 Mar 2016 03:48:12 +0100 Subject: NMS: Various performance tweaks --- web/nms-public.gathering.org/api/public/dhcp-summary | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'web/nms-public.gathering.org/api/public/dhcp-summary') diff --git a/web/nms-public.gathering.org/api/public/dhcp-summary b/web/nms-public.gathering.org/api/public/dhcp-summary index dd643b2..a0e5609 100755 --- a/web/nms-public.gathering.org/api/public/dhcp-summary +++ b/web/nms-public.gathering.org/api/public/dhcp-summary @@ -5,16 +5,11 @@ use warnings; use nms::web; nms::web::setwhen('2h'); -my $q = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp;"); -$q->execute(); -while (my $ref = $q->fetchrow_hashref()) { - $nms::web::json{'dhcp'}{'total'} = $ref; -} my $q2 = $nms::web::dbh->prepare("select count(distinct mac) as clients,count(distinct ip) as addresses,count(mac) as acks from dhcp where $nms::web::when;"); $q2->execute(); while (my $ref = $q2->fetchrow_hashref()) { - $nms::web::json{'dhcp'}{'recent'} = $ref; + $nms::web::json{'dhcp'} = $ref; } $nms::web::cc{'max-age'} = "10"; $nms::web::cc{'stale-while-revalidate'} = "15"; -- cgit v1.2.3