Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

cmdGen.nextCmd out of sync

2014-02-10
2014-02-13
  • Robert Jacobs
    Robert Jacobs
    2014-02-10

    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.10', 'Result1'],
        ['somewhere.3.10', 'Result3'],
        ['somewhere.3.10', 'Result3'], 
        ['somewhere.1.20', 'Result21'],
        ['somewhere.3.20', 'Result23'],
        ['somewhere.3.20', 'Result23'] ]
    

    or

    [   
        ['somewhere.1.10', 'Result1'],
        [None, None],
        ['somewhere.3.10', 'Result3'],
        ['somewhere.1.20', 'Result21'],
        [None, None],
        ['somewhere.3.20', 'Result23']
        ]
    

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