blob: f69ca62ecdc32ce6878cdc21384d21d827ffdc5e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
#! /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();
|