| #!/usr/local/bin/perl5 |
| |
| $rtopmib = ".1.3.6.1.4.10.50"; |
| $rtopid = 2; |
| $rtopmibnamedef = 'top'; |
| $rtopnode = 101; |
| %psmibs = ( |
| 'conf' => 1 , |
| 'top' => 2 , |
| 'ps' => 3 |
| ); |
| |
| while ($_ = $ARGV[0], /^-/) { |
| shift; |
| /^-m/ && (($rtopmib) = shift); |
| /^-i/ && (($rtopid) = shift); |
| /^-n/ && (($rtopnode) = shift); |
| /^-p/ && do { $tmp = shift; |
| if ($psmibs{$tmp}) { |
| (($rtopid) = $psmibs{$tmp}); |
| } |
| else { |
| print "Unknown program: $tmp\n"; |
| print "Pick one of:\t "; |
| foreach $i (keys(%psmibs)) { |
| print "$i "; |
| } |
| print"\n"; |
| exit(1); |
| } |
| } ; |
| /^-h/ && do { &usage(); exit(0);}; |
| } |
| |
| |
| foreach $i (@ARGV) { |
| open(OUT,"/usr/local/etc/snmpwalk -v 1 $i public $rtopmib.$rtopid.$rtopnode | grep -v End|"); |
| while (<OUT>) { |
| s/[^\"]*\"([^\"]*)\".*$/$1/; |
| s/\.$//; |
| print; |
| } |
| } |
| |
| sub usage { |
| $keys = keys(%psmibs); |
| print " |
| usage: rsnmp [options] host [host ...] |
| |
| options: |
| \t-m MIB-MAIN\tMib Number\t(default: $rtopmib) |
| \t-i MIB-IDENT\tMib subnumber\t(default: $rtopid) |
| \t-n MIB-NODE\tMib subnode\t(default: $rtopnode) |
| \t-p NAME\t\tMib Name to use\t(default: $rtopmibnamedef) |
| \t\t\tPick one of:\t"; |
| foreach $i (keys(%psmibs)) { |
| print "$i "; |
| } |
| print " |
| |
| \t-h\t\tThis message |
| "; |
| } |