From 2971d19f9835b0787813af22fd6bad3a6aca88e7 Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Sun, 20 Mar 2016 13:05:08 +0000 Subject: NMS: Add dhcp-summary --- web/nms.gathering.org/api/public/dhcp-summary | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 web/nms.gathering.org/api/public/dhcp-summary (limited to 'web/nms.gathering.org/api/public/dhcp-summary') diff --git a/web/nms.gathering.org/api/public/dhcp-summary b/web/nms.gathering.org/api/public/dhcp-summary new file mode 100755 index 0000000..31bc8eb --- /dev/null +++ b/web/nms.gathering.org/api/public/dhcp-summary @@ -0,0 +1,19 @@ +#! /usr/bin/perl +use lib '../../../../include'; +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