0

I am trying to retrieve some columns in an snmp table. Depending on the permissions of the agent, sometimes columns are not returned. When that happens, the OID of the next valid response is duplicated in the varBindTable.

Is there any marker or flat that shows that the row does not contain what I requested? My application expects the result to be the same as the input.

How is a programmer supposed to notice that something is wrong with the data.

Lets start with an example: This the high level synchronous version. I am grabbing a table where the number of rows and their indexes are not known in advance.

from pysnmp.entity.rfc3413.oneliner import cmdgen

cmdGen = cmdgen.CommandGenerator()

errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
    cmdgen.CommunityData('public', mpModel=0),
    cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
    'somewhere.1',
    'somewhere.2,
    'somewhere.3,
)

Lets assume that 1 and 3 exist and 2 does not. Also lets assume that these are part of a table with indexes rows of 10 and 20. What should be in varBindTable?

[   ['somewhere.1', 'Result1'],
    ['somewhere.3', 'Result3'],
    ['somewhere.3', 'Result3'] ]

or

[   ['somewhere.1', 'Result1'],
    [None, None],
    ['somewhere.3', 'Result3'] ]

I get the first. It would be nice if I got the second. Whats the point of the duplicate garbage data?

Robert Jacobs
  • 3,266
  • 1
  • 20
  • 30

1 Answers1

0

When an OID is not available, agent skips it and proceeds with the next OID it has.

So if your Agent has, say, OIDs 1, 2 and 3 when access to all these OIDs is permitted, you request GETNEXT 1 and 2, you receive 2 and 3 in response. When access to OID 2 is denied, you request GETNEXT 1 and 2, you receive 3 and 3 (as 2 is skipped by Agent).

To prove this you could enable pysnmp debugging and see what OIDs are actually exchanged between your Manager and Agent.

To you are looking for a specific OID and want to see if it's available, just use GET request and Agent will either respond with a value or an error.

Pooh
  • 276
  • 1
  • 3
  • I added an example above. Notice that I am using the synchronous version and that I am retrieving a table – Robert Jacobs Feb 10 '14 at 14:07
  • There should be no difference whether you are using sync or async interface, query scalars or tables. Taking your example, correct response would be [ ['somewhere.3', 'Result3'],['somewhere.3', 'Result3'], ['somewhere.4', 'Result4'] ] as the 'NEXT' OID past somewhere.1 is somewhere.2 but since it's absent, Agent would skip it and respond with somewhere.3 which is next available OID. Does it make sense? There is no way with GETNEXT type query you could sense a present but unavailable OID. Use GET query type for that. – Pooh Feb 13 '14 at 18:23