From 9317bfc07c0fb7ef0fbbf3afa3a0cba293d3184e Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Mon, 21 Mar 2016 22:26:31 +0100 Subject: NMS: Add DHCP API --- web/nms.gathering.org/api/public/dhcp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 web/nms.gathering.org/api/public/dhcp (limited to 'web/nms.gathering.org/api/public/dhcp') diff --git a/web/nms.gathering.org/api/public/dhcp b/web/nms.gathering.org/api/public/dhcp new file mode 100755 index 0000000..d432af0 --- /dev/null +++ b/web/nms.gathering.org/api/public/dhcp @@ -0,0 +1,19 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use lib '../../../../include'; +use nms::web qw (%json finalize_output); +use strict; +use warnings; +use Data::Dumper; + +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 . ' order by sysname,time desc;'); +$q->execute(); +while ( my $ref = $q->fetchrow_hashref() ) { + my $sysname = $ref->{'sysname'}; + $json{'dhcp'}{$ref->{'sysname'}} = $ref->{'time'}; +} + +$nms::web::cc{'max-age'} = "5"; +$nms::web::cc{'stale-while-revalidate'} = "30"; +finalize_output(); -- cgit v1.2.3 From 89c78bc9eab3b69fe31babe5e64f0343386f67be Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 22 Mar 2016 15:06:50 +0100 Subject: NMS: DHCP map --- web/nms.gathering.org/api/public/dhcp | 1 + 1 file changed, 1 insertion(+) (limited to 'web/nms.gathering.org/api/public/dhcp') diff --git a/web/nms.gathering.org/api/public/dhcp b/web/nms.gathering.org/api/public/dhcp index d432af0..91d52af 100755 --- a/web/nms.gathering.org/api/public/dhcp +++ b/web/nms.gathering.org/api/public/dhcp @@ -7,6 +7,7 @@ use strict; 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 . ' order by sysname,time desc;'); $q->execute(); while ( my $ref = $q->fetchrow_hashref() ) { -- 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.gathering.org/api/public/dhcp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'web/nms.gathering.org/api/public/dhcp') diff --git a/web/nms.gathering.org/api/public/dhcp b/web/nms.gathering.org/api/public/dhcp index 91d52af..7b048d1 100755 --- a/web/nms.gathering.org/api/public/dhcp +++ b/web/nms.gathering.org/api/public/dhcp @@ -15,6 +15,6 @@ while ( my $ref = $q->fetchrow_hashref() ) { $json{'dhcp'}{$ref->{'sysname'}} = $ref->{'time'}; } -$nms::web::cc{'max-age'} = "5"; +$nms::web::cc{'max-age'} = "10"; $nms::web::cc{'stale-while-revalidate'} = "30"; finalize_output(); -- cgit v1.2.3