File: tablewalk.pl

package info (click to toggle)
net-snmp 5.9.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 38,720 kB
  • sloc: ansic: 282,878; perl: 17,704; sh: 12,151; makefile: 2,711; python: 734; xml: 663; pascal: 62; sql: 47
file content (19 lines) | stat: -rw-r--r-- 597 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# snmpwalk of a single table
# getnext of 3 columns from ipAddrEntry table
# stop after last row in table

use SNMP 1.8;

my $host = shift || localhost;
my $comm = shift || public;

my $sess = new SNMP::Session ( DestHost => $host, Community => $comm );

my $vars = new SNMP::VarList([ipAdEntAddr],[ipAdEntIfIndex],[ipAdEntNetMask]);

for (@vals = $sess->getnext($vars);
     $vars->[0]->tag =~ /ipAdEntAddr/       # still in table
     and not $sess->{ErrorStr};          # and not end of mib or other error
     @vals = $sess->getnext($vars)) {
     print "   ($vals[1]) $vals[0]/$vals[2]\n";
}