projects
/
pxelator
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
e8507ab
)
use hostname from snmp
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 28 Nov 2010 20:35:02 +0000
(20:35 +0000)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Sun, 28 Nov 2010 20:35:02 +0000
(20:35 +0000)
bin/snmp-printer.pl
patch
|
blob
|
history
diff --git
a/bin/snmp-printer.pl
b/bin/snmp-printer.pl
index
8311c44
..
19c8e50
100755
(executable)
--- 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 Data::Dump qw(dump);
use File::Path;
+use lib 'lib/PXElator';
+use client;
+
my $dir = 'conf/ip';
use JSON;
sub save_json {
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";
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;
}
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
# 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
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