SNMP4J dynamic index value

787 views Asked by At

I am trying to build a client to get values from an snmp enabled device using snmp4j. Using the OID and index number i can fetch the name and serial number of the device. But i heard that index number is not constant and it keeps changing. Thou i may find the required index number (for example, of a network interface) among the SNMP OIDs, sometimes we may not completely rely on the index number always staying the same.

Index numbers may be dynamic - they may change over time and your item may stop working as a consequence.

SO i need to find a way as to how to fetch the index number dynamically. Or is there any way that i can get the serial number without hard coding the serial number.

One OID might have 150 index numbers each having an different value. i need to get a particular info from that table.

1

There are 1 answers

0
Jolta On

It's (unfortunately) not unusual that index numbers change. For example, some equipment will re-order some tables on reboot.

You probably already realized that if the index values are volatile, you won't be able to fetch the data in one request. But you could do it by "walking" the table.

Using the GetNextRequest, you can start at the column headers, and then proceed through the table, fetching all the data or just individual columns. For a more detailed example, see section 4.2.2.1 of RFC 1905: https://www.rfc-editor.org/rfc/rfc1905

Assuming that there is some column in the table which will identify the correct card, you could either:

  1. Walk only the identifying column, and from the values find the index of the card you want, then issue a single GetRequest for the serial number of that card

  2. (More efficient) Walk both columns (identifier and serial number) by requesting those two column headers in the first request, etc. In the resulting data set, find the data for you card.