Subject: | session error message non-existant |
Date: | Sun, 7 Jun 2009 08:26:49 -0400 |
To: | bug-Net-SNMP [...] rt.cpan.org |
From: | Tim Epkes <tim [...] epkes.net> |
I have been working with Net::SNMP and noticed that when it cannot reach the
host it doesn't give and error during the initial session set up as follows:
-------------------------------------------------------------------------------------------------------------
my ($session, $error) = Net::SNMP->session(
-version => 'snmpv2c',
-nonblocking => 0,
-hostname => $address,
-community => 'public',
-port => 161
);
if (!defined($session)) {
printf ("Session Error %s %s Thread $tid ERROR: %s.\n",
uc($app),$address,$error);
{
lock($diesignal);
$diesignal=0;
}
}
-------------------------------------------------------------------------------------------------------------
As $session always get assigned a hash. I then thought, testing for
$session->error would be good, but it always comes back with nothing. I did
a loop through the keys on an address that I could not reach (so their
should have been an error returned) and got the following:
-------------------------------------------------------------------------------------------------------------
KEY: _translate equals 255
KEY: _security equals Net::SNMP::Security::Community=HASH(0xaaf5618)
KEY: _transport_argv equals ARRAY(0xaaf53a8)
KEY: _pdu equals
KEY: _callback equals
KEY: _nonblocking equals 0
KEY: _version equals 1
KEY: _transport equals Net::SNMP::Transport::UDP=HASH(0xaaf5648)
*KEY: _error equals *
KEY: _context_engine_id equals
KEY: _context_name equals
KEY: _delay equals 0
KEY: _discovery_queue equals ARRAY(0xaaf5388)
KEY: _hostname equals 10.10.10.10
-------------------------------------------------------------------------------------------------------------
As you can see Error returns nothing, even though the host I was querying
was definitely unreachable.
Thanks
Tim