From 06aad5822ec9630f23284f85ad057027e7448a3e Mon Sep 17 00:00:00 2001 From: Kristian Lyngstol Date: Wed, 16 Mar 2016 22:11:07 +0000 Subject: NMS: ... actually add the SNMP API "Untracked files".... --- web/nms.gathering.org/api/private/snmp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 web/nms.gathering.org/api/private/snmp (limited to 'web/nms.gathering.org/api') diff --git a/web/nms.gathering.org/api/private/snmp b/web/nms.gathering.org/api/private/snmp new file mode 100755 index 0000000..4779659 --- /dev/null +++ b/web/nms.gathering.org/api/private/snmp @@ -0,0 +1,29 @@ +#! /usr/bin/perl +# vim:ts=8:sw=8 + +use CGI qw(fatalsToBrowser); +use DBI; +use lib '../../../../include'; +use nms; +use nms::web; +use strict; +use warnings; +use JSON; +use Data::Dumper; + +$nms::web::cc{'max-age'} = "10"; + +my $q = $nms::web::dbh->prepare('select sysname,data from snmp natural join switches where id in (select max(id) from snmp where ' . $nms::web::when . 'group by switch);'); + +$q->execute(); +while (my $ref = $q->fetchrow_hashref()) { + my $sysname = $ref->{'sysname'}; + + # This is, strictly speaking, redundant. But by doing this, we can + # re-use the standard methods of finalize_output() and whatnot. + my $data = JSON::XS::decode_json($ref->{'data'}); + + $nms::web::json{'snmp'}{$ref->{'sysname'}} = $data; +} + +finalize_output(); -- cgit v1.2.3