From 05fedaa7461c6fd67c402671f0e129b3d1772fbf Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Tue, 22 Mar 2016 19:53:30 +0100 Subject: NMS: Tweak NMS public API and draw linknets --- web/nms-public.gathering.org/api/public/dhcp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 web/nms-public.gathering.org/api/public/dhcp (limited to 'web/nms-public.gathering.org/api/public/dhcp') diff --git a/web/nms-public.gathering.org/api/public/dhcp b/web/nms-public.gathering.org/api/public/dhcp new file mode 100755 index 0000000..91d52af --- /dev/null +++ b/web/nms-public.gathering.org/api/public/dhcp @@ -0,0 +1,20 @@ +#! /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; + +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() ) { + 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