SNP vs Net::SNMP Connections and Error Stringsby wveagle81 (Novice)
|on Aug 04, 2015 at 22:10 UTC||Need Help??|
wveagle81 has asked for the
wisdom of the Perl Monks concerning the following question:
I'm working with the SNMP module to query equipment. I've got a situation where there appears to be a connection to the equipment but it really isn't. I'm trying to figure out how to handle these situations. I've spent several hours this afternoon trying to find the answer and have given up on finding it myself. That's where you fine folks who've helped me before come in...
BTW, I'm doing all of this on a closed network so I can't post complete code samples. Sorry.
First, if I run snmpwalk against equipment "A" I get an error that says "snmpwalk: Unknown user name". If I then run snmpwalk against equipment "B" it returns proper data. So my user on the server is set up correctly.
Here's the dilemma. If I use the SNMP module to connect to "A" it seems to connect and gives me a session variable and everything (verified with Data::Dumper) and the ErrorNum is 0. BUT if I try to run a get against that session, I get nothing back.
If I change to the Net::SNMP module and connect to "A" I get an error message that says "Received usmStatsUnknownUserNames.0"
Where is the discrepancy, and how can I handle this error using the SNMP module? I don't want to use Net::SNMP because I don't want to have to look up all of the OID numbers for the (many) variables and tables I need to get data for.
In addition, using snmpwalk there is equipment "C" which times out. Using SNMP I get an error but when I print the $SNMP::Session::ErrorStr variable, I get nothing. All of the code samples I've been able to find use this convention but it doesn't seem to work for me. (See below code sample)die "Session Error: $SNMP::Session::ErrorStr\n" unless (defined $session)
Thanks for any help you can throw my way.