/[pxelator]/bin/snmp-printer.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /bin/snmp-printer.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 553 by dpavlin, Sun Nov 28 20:25:22 2010 UTC revision 554 by dpavlin, Sun Nov 28 20:35:02 2010 UTC
# Line 8  use SNMP::Multi; Line 8  use SNMP::Multi;
8  use Data::Dump qw(dump);  use Data::Dump qw(dump);
9  use File::Path;  use File::Path;
10    
11    use lib 'lib/PXElator';
12    use client;
13    
14  my $dir = 'conf/ip';  my $dir = 'conf/ip';
15    
16  use JSON;  use JSON;
17  sub save_json {  sub save_json {
18          my ( $path, $json ) = @_;          my ( $ip, $json ) = @_;
19          mkpath "$dir/$path" unless -d "$dir/$path";          mkpath "$dir/$ip" unless -d "$dir/$ip";
20          $path = "$dir/$path/snmp-printer.json";          my $path = "$dir/$ip/snmp-printer.json";
21          open(my $fh, '>', $path) || die "$path: $!";          open(my $fh, '>', $path) || die "$path: $!";
22          print $fh encode_json $json;          print $fh encode_json $json;
23          close($fh);          close($fh);
24          warn "# $path ", -s $path, " bytes\n";          warn "# $path ", -s $path, " bytes\n";
25            client::conf( $ip => 'hostname', default => $json->{hostname} )
26  }  }
27    
28  my $debug = $ENV{DEBUG} || 0;  my $debug = $ENV{DEBUG} || 0;
# Line 31  my @printers = map { s{^conf/ip/([0-9\.] Line 35  my @printers = map { s{^conf/ip/([0-9\.]
35  # remove final .1 since we are using bulkwalk to get values!  # remove final .1 since we are using bulkwalk to get values!
36  my %vars = qw[  my %vars = qw[
37  info                            iso.3.6.1.2.1.1.1.0  info                            iso.3.6.1.2.1.1.1.0
38  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
39  serial                          iso.3.6.1.2.1.43.5.1.1.17.1  serial                          iso.3.6.1.2.1.43.5.1.1.17.1
40  pages                           iso.3.6.1.2.1.43.10.2.1.4.1  pages                           iso.3.6.1.2.1.43.10.2.1.4.1
41  @message                        iso.3.6.1.2.1.43.18.1.1.8  @message                        iso.3.6.1.2.1.43.18.1.1.8

Legend:
Removed from v.553  
changed lines
  Added in v.554

  ViewVC Help
Powered by ViewVC 1.1.26