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.


In reply to SNP vs Net::SNMP Connections and Error Strings by wveagle81

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.