1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/usr/local/bin/perl
#Check for SNMP Values
use BER;
require 'SNMP_Session.pm';
#Variables
$host=@ARGV[0] || die "usage";
$community=@ARGV[1] || 'public';
$port='161';
$session = SNMP_Session->open ($host, $community, $port)
|| die "Couldn't open SNMP session to $host";
#Oid's
$oid1=encode_oid (1,3,6,1,2,1,1,5,0);
if ($session->get_request_response ($oid1)){
($bindings) = $session->decode_get_response
($session->{pdu_buffer});
while ($bindings ne '') {
($binding,$bindings) = &decode_sequence ($bindings);
($oid,$value) = &decode_by_template ($binding, "%O%@");
print $pretty_oids{$oid}," => ",
&pretty_print ($value), "\n";
}
} else {
die "No response from agent on $host";
}
|