From 4c716811ae1a0413fa2c75b7c9817b507dc6356d Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Mon, 29 Nov 2010 14:55:06 +0100 Subject: [PATCH] store date and ip --- scripts/snmp-printer.pl | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/snmp-printer.pl b/scripts/snmp-printer.pl index 2f74a38..d12504d 100755 --- a/scripts/snmp-printer.pl +++ b/scripts/snmp-printer.pl @@ -23,6 +23,11 @@ sub save_json { warn "# $path ", -s $path, " bytes\n"; } +sub iso_datetime { + my ($ss,$mm,$hh,$d,$m,$y) = localtime(time); + return sprintf "%04d-%02d-%02dT%02d:%02d:%02d", $y+1900, $m, $d, $hh, $mm, $ss; +} + my $debug = $ENV{DEBUG} || 0; my $community = 'public'; @@ -140,6 +145,8 @@ foreach my $host ( $resp->hosts ) { delete $status->{$group}; } + $status->{ip} = $host->hostname; + $status->{date} = iso_datetime; print "$host = ",dump($status); save_json $host => $status; $collected->{$host} = $status; -- 2.20.1