If your IP addresses are getting jumbled up you now have to ask yourself: "are all my values that are returned on the same row?"

If it is at all possible that particular rows have a field missing then your individual column getnexts are going to get out of sync.. you may be retrieving share name for row 12 while retrieving comment for row 15.

To guard against this you are going to have to harvest the last integer from the OID of each column and ensure they are all the same. (The last OID of each column is the row number, or more accurately, the index of the row.. actually the index might be an IP address and consist of many integers.. The only right way to obtain the row number is to strip off the leading digits that match the OID of the variable you are getting - confused yet?).

ie. let's say you have an object called myEnglishCol with OID 1.3.6.1.7.1.3 and an object called myFrenchCol with OID 1.3.6.1.7.1.4.

You then do a getnext on these two objects and you get back the following:

getnext( "1.3.6.1.7.1.3", "1.3.6.1.7.1.4" ); 1.3.6.1.7.1.3.14.15.16 - "Hello" 1.3.6.1.7.1.4.14.15.16 - "Bonjour"
.. in this situation you are returned row "14.15.16" for both the myEnglishCol and myFrenchCol objects.

Now let's say you do a getnext on this:

getnext( "1.3.6.1.7.1.3.14.15.16", "1.3.6.1.7.1.4.14.15.16" ); 1.3.6.1.7.1.3.14.15.17 - "Goodbye" 1.3.6.1.7.1.4.14.15.19 - "Non"
.. clearly something has gone wrong. Maybe there was no translation available for the word "Goodbye" so there is no myFrenchCol.14.15.17 object. Because the two row numbers (14.15.17 and 14.15.19) don't match up you should consider rejecting this whole row. Your next attempt at a getnext should be:
getnext( "1.3.6.1.7.1.3.14.15.17", "1.3.6.1.7.1.4.14.15.17" ); 1.3.6.1.7.1.3.14.15.19 - "No" 1.3.6.1.7.1.4.14.15.19 - "Non"

So you might want to consider using OIDs directly in your code instead of "magic" auto-MIB interpreting stuff. You might want to do something like:

my $myFrenchCol = '1.3.6.1.7.1.3'; my $myEnglishCol = '1.3.6.1.7.1.4'; my $row = ""; while ( 1 ) { my ( $rF, $rE ) = getnext( $myFrenchCol . $row, $myEnglishCol . $row ); if ( $rE =~ m/^$myEnglishCol(.+)$/ ) { $row = $1; if ( $rF !~ m/^$myFrenchCol($row)$/ ) { print( Results on different rows\n"; next; } # match! process results.. and continue next; } else { # got something funny back, maybe run out of rows last; } }

Whilst SNMP is a simple protocol to implement, it's not so simple to use.. you have my empathy.


In reply to Re^3: SNMP from script conflicts with snmpwalk by monarch
in thread SNMP from script conflicts with snmpwalk by bowei_99

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.