X-Git-Url: http://git.rot13.org/?p=snmp-json.git;a=blobdiff_plain;f=printer-multi.pl;h=0fbb3299e330bdbbc6dae6e6f73a90ba97779834;hp=35ad6bc9d34382d29f30571055c4e573a0d9c91d;hb=14227fdd3ead9aeab754d9cdfe1593f31ba5332c;hpb=a7cb26f717dc97ccae13461b07f3b59e27ff0ab6 diff --git a/printer-multi.pl b/printer-multi.pl index 35ad6bc..0fbb329 100755 --- a/printer-multi.pl +++ b/printer-multi.pl @@ -5,6 +5,9 @@ use strict; use SNMP::Multi; use Data::Dump qw(dump); +use JSON; +my $json; + my $debug = $ENV{DEBUG} || 0; my $community = 'public'; @@ -40,6 +43,11 @@ pages iso.3.6.1.2.1.43.10.2.1.4.1 @consumable_name iso.3.6.1.2.1.43.11.1.1.6.1 @consumable_max iso.3.6.1.2.1.43.11.1.1.8.1 @consumable_curr iso.3.6.1.2.1.43.11.1.1.9.1 +@tray_max iso.3.6.1.2.1.43.8.2.1.9.1 +@tray_capacity iso.3.6.1.2.1.43.8.2.1.10.1 +@tray_name iso.3.6.1.2.1.43.8.2.1.13.1 +@tray_dim_x iso.3.6.1.2.1.43.8.2.1.4.1 +@tray_dim_y iso.3.6.1.2.1.43.8.2.1.5.1 ]; my $oid2name; @@ -67,6 +75,8 @@ warn "# working on: ", join(' ', @printers),$/; my $resp = $sm->execute() or die $sm->error(); +my $collected; + foreach my $host ( $resp->hosts ) { my $status; @@ -114,5 +124,15 @@ foreach my $host ( $resp->hosts ) { } print "$host = ",dump($status); + $collected->{$host} = $status; } +# generate json +my $json; +foreach my $ip ( sort keys %$collected ) { + my $status = $collected->{$ip}; + $status->{ip} = $ip; + push @$json, $status; +} +open(my $fh, '>', 'printer.json'); +print $fh encode_json $json;