File: mibtree.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 (20 lines) | stat: -rw-r--r-- 676 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
20
use SNMP;
$SNMP::save_descriptions = 1; # must be set prior to mib initialization
SNMP::initMib(); # parses default list of Mib modules from default dirs

# read dotted decimal oid or symbolic name to look up
# partial name will be searched and all matches returned
$val = shift || die "supply partial or complete object name or identifier\n";

if ($node = $SNMP::MIB{$val}) {
    print "$node:$node->{label} [$node->{objectID}]\n";
    while (($k,$v) = each %$node) {
	print "\t$k => $v\n";
    }
} else {
    while (($k,$v) = each %SNMP::MIB) {
	print "$v->{label} [$v->{obj}]\n" #accepts unique partial key(objectID)
	    if $k =~ /$val/ or $v->{label} =~ /$val/;
    }
}