I had a look at your code. There could be many problems as you have not described what errors or symptoms you're receiving.

First, the good news. You've got lots of error checking there and die statements to protect you from bad coding. Well done, I can only encourage this!

The bad news: you do a getnext on sysName. Thus I presume you will get sysName.0 because all scalar SNMP objects (ie objects that are NOT columnar), by definition, have a trailing .0 in the object identifier.

However, assuming sysName is a columnar object, you still have problems because you're assuming that the sysName column is in the same table as the prtCoverStatus. And they clearly are NOT in the same table because their OIDs (object identifiers) are different lengths let alone in different parts of the address space.

I could be wrong, however. Maybe the sysName object is in a table with an index of type OCTET STRING. So you're trying to capture the name of a device from the table the sysName object is in and then look in the table the prtCoverStatus object is in that is presumably indexed by device name as an OCTET STRING too???

Can you see that you need to assist us by describing a) what is your objective and b) how, specifically, is this failing?


Lastly - the last line of your script closes your SNMP object after it first discovers an answer. Is this what you mean to do? Or do you mean to close the SNMP object AFTER polling ALL devices?


In reply to Re: Where is the bug in this Net::SNMP code? by monarch
in thread Where is the bug in this Net::SNMP code? by tolyan77

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.