/[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 551 by dpavlin, Sun Nov 28 19:52:58 2010 UTC revision 552 by dpavlin, Sun Nov 28 20:25:22 2010 UTC
# Line 6  use strict; Line 6  use strict;
6    
7  use SNMP::Multi;  use SNMP::Multi;
8  use Data::Dump qw(dump);  use Data::Dump qw(dump);
9    use File::Path;
10    
11  my $dir = 'json/printer';  my $dir = 'conf/ip';
12    
13  use JSON;  use JSON;
14  sub save_json {  sub save_json {
15          my ( $path, $json ) = @_;          my ( $path, $json ) = @_;
16          $path = "$dir/$path";          mkpath "$dir/$path" unless -d "$dir/$path";
17          open(my $fh, '>', $path);          $path = "$dir/$path/snmp-printer.json";
18            open(my $fh, '>', $path) || die "$path: $!";
19          print $fh encode_json $json;          print $fh encode_json $json;
20          close($fh);          close($fh);
21          warn "# $path ", -s $path, " bytes\n";          warn "# $path ", -s $path, " bytes\n";
# Line 22  sub save_json { Line 24  sub save_json {
24  my $debug = $ENV{DEBUG} || 0;  my $debug = $ENV{DEBUG} || 0;
25    
26  my $community = 'public';  my $community = 'public';
27  my @printers = qw(  my @printers = map { s{^conf/ip/([0-9\.]+)/.+$}{$1}; $_ } glob 'conf/ip/*/snmp-printer*';
 10.60.0.20  
   
 10.60.3.15  
 10.60.3.17  
   
 10.60.3.19  
 10.60.3.21  
   
 10.60.3.23  
 10.60.3.25  
   
 10.60.3.27  
 10.60.3.29  
   
 10.60.3.31  
 10.60.3.33  
   
 10.60.3.35  
 10.60.3.37  
 );  
28    
29  @printers = @ARGV if @ARGV;  @printers = @ARGV if @ARGV;
30    

Legend:
Removed from v.551  
changed lines
  Added in v.552

  ViewVC Help
Powered by ViewVC 1.1.26