Greetings. I'm doing SNMP programming using PySNMP and Python. In my application, I'll be talking with several different devices that are all performing a similar function, but the internal SNMP implementations are very different from each other. In most of them, I'm retrieving tables of information and then parsing them to glean the information I need.

I'm having trouble deciding how to structure the code. I have the OID of the table, of course. I have tried stripping the base OID from the retrieved values, leaving the fields and index entries. Then I have a series of if/elif statements to test which field is being read.

Also, I have some systems where I get data from two different tables, and I have to combine the data once it is all retrieved. I've been storing results in a list and then retraversing the list when the new information is found, but it feels inefficient. Anyone have thoughts on this?

How have you been storing OIDs? Tuple of integers? Dotted string? I have found the dotted string easier to manipulate, but I don't know how efficient it is.

I'm not looking for a particular solution, just want to spark discussion on SNMP programming style.

6 Years
Discussion Span
Last Post by pyTony

Using dictionaries with their very well optimized hash functiones and flexibility often leads to more clear and efficient code.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.