diff options
author | Kristian Lyngstol <kly@kly.no> | 2016-03-20 13:05:08 +0000 |
---|---|---|
committer | Magnus Kirø <magnuskiro@gmail.com> | 2016-03-20 18:06:08 +0100 |
commit | 2971d19f9835b0787813af22fd6bad3a6aca88e7 (patch) | |
tree | dd91396119c85c11b8ac74ee5183a796f22c8cad | |
parent | b2f71d875810476af383c0cfcf8e633a0fdb84f0 (diff) |
NMS: Add dhcp-summary
-rwxr-xr-x | web/nms.gathering.org/api/public/dhcp-summary | 19 | ||||
-rw-r--r-- | web/nms.gathering.org/js/nms.js | 1 |
2 files changed, 20 insertions, 0 deletions
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(); diff --git a/web/nms.gathering.org/js/nms.js b/web/nms.gathering.org/js/nms.js index 1270a7f..bf13c57 100644 --- a/web/nms.gathering.org/js/nms.js +++ b/web/nms.gathering.org/js/nms.js @@ -465,6 +465,7 @@ function initNMS() { nmsData.registerSource("ping", "/api/public/ping"); nmsData.registerSource("switches","/api/public/switches"); nmsData.registerSource("switchstate","/api/public/switch-state"); + nmsData.registerSource("dhcpsummary","/api/public/dhcp-summary"); // This is a magic dummy-source, it's purpose is to give a unified // way to get ticks every second. It is mainly meant to allow map |