From fa828ce79c48fbf36b4dfa9b186db43eb67d4701 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Sun, 28 Nov 2010 20:35:02 +0000 Subject: [PATCH 1/1] use hostname from snmp --- bin/snmp-printer.pl | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 -- 2.20.1