projects
/
angular-mojolicious.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
store date and ip
[angular-mojolicious.git]
/
scripts
/
snmp-printer.pl
diff --git
a/scripts/snmp-printer.pl
b/scripts/snmp-printer.pl
index
7052394
..
d12504d
100755
(executable)
--- a/
scripts/snmp-printer.pl
+++ b/
scripts/snmp-printer.pl
@@
-3,6
+3,9
@@
use warnings;
use strict;
# pull info from SNMP enabled printers and dump JSON
use strict;
# pull info from SNMP enabled printers and dump JSON
+#
+# dump all snmp data on printer with:
+# snmpwalk -c public -v 1 10.60.3.15
use SNMP::Multi;
use Data::Dump qw(dump);
use SNMP::Multi;
use Data::Dump qw(dump);
@@
-20,6
+23,11
@@
sub save_json {
warn "# $path ", -s $path, " bytes\n";
}
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';
my $debug = $ENV{DEBUG} || 0;
my $community = 'public';
@@
-137,6
+145,8
@@
foreach my $host ( $resp->hosts ) {
delete $status->{$group};
}
delete $status->{$group};
}
+ $status->{ip} = $host->hostname;
+ $status->{date} = iso_datetime;
print "$host = ",dump($status);
save_json $host => $status;
$collected->{$host} = $status;
print "$host = ",dump($status);
save_json $host => $status;
$collected->{$host} = $status;