aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms.gathering.org/api/private/snmp
diff options
context:
space:
mode:
authorKristian Lyngstol <kly@kly.no>2016-03-17 19:51:46 +0000
committerKristian Lyngstol <kly@kly.no>2016-03-17 19:51:46 +0000
commit5c9d6d10dc7e53a8d06fbd056ded591a6b583167 (patch)
tree6f6290fb1b8bcc859278a2c68573a35547173931 /web/nms.gathering.org/api/private/snmp
parent76a3aad5090d304ec0f76f28e50afe1f53b7b96c (diff)
parent025f01e7e8c5bfea21b559fbac650f90c2774a29 (diff)
Merge branch 'master' of https://github.com/tech-server/tgmanage
Diffstat (limited to 'web/nms.gathering.org/api/private/snmp')
-rwxr-xr-xweb/nms.gathering.org/api/private/snmp29
1 files changed, 29 insertions, 0 deletions
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();