aboutsummaryrefslogtreecommitdiffstats
path: root/web/nms-public.gathering.org/old/dhcp-json.pl
diff options
context:
space:
mode:
authorMagnus Kirø <magnuskiro@gmail.com>2016-03-22 11:14:46 +0100
committerMagnus Kirø <magnuskiro@gmail.com>2016-03-22 11:14:46 +0100
commit7806081670c8c9807fc8b6628b3d7a6eff841ded (patch)
tree082e522b99cd5b864a8963523f2b3889f6cff808 /web/nms-public.gathering.org/old/dhcp-json.pl
parente501dd7dd88bf52edd914a8f078141b91d53939b (diff)
parent2d19233ba32fd23ad7182d3cccb58cec9e377a75 (diff)
MERGE fix.
Diffstat (limited to 'web/nms-public.gathering.org/old/dhcp-json.pl')
-rwxr-xr-xweb/nms-public.gathering.org/old/dhcp-json.pl19
1 files changed, 19 insertions, 0 deletions
diff --git a/web/nms-public.gathering.org/old/dhcp-json.pl b/web/nms-public.gathering.org/old/dhcp-json.pl
new file mode 100755
index 0000000..210c434
--- /dev/null
+++ b/web/nms-public.gathering.org/old/dhcp-json.pl
@@ -0,0 +1,19 @@
+#! /usr/bin/perl
+use CGI qw(fatalsToBrowser);
+use DBI;
+use lib '../../include';
+use nms;
+my $cgi = CGI->new;
+
+my $dbh = nms::db_connect();
+
+my $q = $dbh->prepare('select sysname,EXTRACT(EPOCH FROM last_ack) as last_ack from switches natural join dhcp ');
+$q->execute();
+
+my %json = ();
+while (my $ref = $q->fetchrow_hashref()) {
+ $json{'dhcp'}{$ref->{'sysname'}}{'last_ack'} = $ref->{'last_ack'};
+}
+$dbh->disconnect;
+print $cgi->header(-type=>'text/json; charset=utf-8');
+print JSON::XS::encode_json(\%json);