Purpose - I want to browse to select mac addresses from the snmp table.

cmdGen = cmdgen.CommandGenerator() cmdGen.ignoreNonIncreasingOid = True errorIndication, errorStatus, errorIndex, \ varBindTable = cmdGen.nextCmd( cmdgen.CommunityData(community, community), cmdgen.UdpTransportTarget((hostname, 161)), dot1dTpFdbTable ) for varBindTableRow in varBindTable: for name, val in varBindTableRow: 

I get varBindTableRow and a bunch of oid in unsorted form. It would be desirable to receive as a result an array arr[id](param1, param2, param3) . Can this be done? How?

    1 answer 1

     errorIndication, errorStatus, errorIndex,varBindTable = cmdgen.CommandGenerator().nextCmd(cmdgen.CommunityData('None','initial_pysnmp'), cmdgen.UdpTransportTarget(('uvr-24',161)),(1,3,6,1,2,1,17,7,1,2,2,1,2)) for varBindTableRow in varBindTable: for name, val in varBindTableRow: vlan = "{0}".format(name[13]) mac = "{0}:{1}:{2}:{3}:{4}:{5}".format(hex(name[14])[2:].zfill(2),hex(name[15])[2:].zfill(2), hex(name[16])[2:].zfill(2),hex(name[17])[2:].zfill(2), hex(name[18])[2:].zfill(2),hex(name[19])[2:].zfill(2)) port = "{0}:{1}".format(int(val.prettyPrint())/64+1,int(val.prettyPrint())%64) print vlan,mac,port 999 00:1c:f0:06:44:d7 1:26 999 00:1c:f0:0d:29:15 1:26 999 00:1c:f0:1a:b9:e5 1:26