aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms-public.gathering.org/api/public/dhcp
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly@.no>2016-03-22 19:53:30 +0100
committerKristian Lyngstol <kly@kly@.no>2016-03-22 19:53:30 +0100
commit05fedaa7461c6fd67c402671f0e129b3d1772fbf (patch)
treea973895e01934566f57ccbd1ec46380950bbf8d6 /web/nms-public.gathering.org/api/public/dhcp
parent79d9099cf563c276f67b07ca2e62fc51f40288be (diff)
NMS: Tweak NMS public API and draw linknets
Diffstat (limited to 'web/nms-public.gathering.org/api/public/dhcp')
-rwxr-xr-xweb/nms-public.gathering.org/api/public/dhcp20
1 files changed, 20 insertions, 0 deletions
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();