X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=bin%2Fsnmp-printer.pl;h=19c8e5071acd1ee91ac9b34460fbc9140018c6b6;hb=HEAD;hp=8311c44736295fe3ae7324a82e94a0052d6db519;hpb=32744ca6e1c741a147f1163afaa4a17e9b468f2d;p=pxelator diff --git a/bin/snmp-printer.pl b/bin/snmp-printer.pl index 8311c44..19c8e50 100755 --- a/bin/snmp-printer.pl +++ b/bin/snmp-printer.pl @@ -8,17 +8,21 @@ use SNMP::Multi; use Data::Dump qw(dump); use File::Path; +use lib 'lib/PXElator'; +use client; + my $dir = 'conf/ip'; use JSON; sub save_json { - my ( $path, $json ) = @_; - mkpath "$dir/$path" unless -d "$dir/$path"; - $path = "$dir/$path/snmp-printer.json"; + my ( $ip, $json ) = @_; + mkpath "$dir/$ip" unless -d "$dir/$ip"; + my $path = "$dir/$ip/snmp-printer.json"; open(my $fh, '>', $path) || die "$path: $!"; print $fh encode_json $json; close($fh); warn "# $path ", -s $path, " bytes\n"; + client::conf( $ip => 'hostname', default => $json->{hostname} ) } my $debug = $ENV{DEBUG} || 0; @@ -31,7 +35,7 @@ my @printers = map { s{^conf/ip/([0-9\.]+)/.+$}{$1}; $_ } glob 'conf/ip/*/snmp-p # remove final .1 since we are using bulkwalk to get values! my %vars = qw[ info iso.3.6.1.2.1.1.1.0 -name iso.3.6.1.2.1.43.5.1.1.16.1 +hostname iso.3.6.1.2.1.43.5.1.1.16.1 serial iso.3.6.1.2.1.43.5.1.1.17.1 pages iso.3.6.1.2.1.43.10.2.1.4.1 @message iso.3.6.1.2.1.43.18.1.1.8