lundi 1 juin 2015

How to initialize a SNMP agent such that I can do a pysnmp nextCmd in a test afterwards?

I want to test one of my plug-ins in which I do a pysnmp nextCmd and for that I have to do a couple of set commands for my agent. I have an SNMP Agent simulator running and I made sure to add: cmdrsp.NextCommandResponder(snmpEngine,snmpContext)

My question is how do I initialize my SNMP agent simulator such that it can return the varBindTable in the nextCmd? This is how I tried to set the values so far:

errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(
  cmdgen.CommunityData('public'),
  cmdgen.UdpTransportTarget(("127.0.0.1", 161)),
  ("1.1.1", pysnmp.proto.rfc1902.Integer(2)))
errorIndication, errorStatus, errorIndex, varBinds = cmdGen.setCmd(
      cmdgen.CommunityData('public'),
      cmdgen.UdpTransportTarget(("127.0.0.1", 161)),
      ("1.1.2", pysnmp.proto.rfc1902.Integer(3)))

And this is the nextCmd:

errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
      cmdgen.CommunityData('public'),
      cmdgen.UdpTransportTarget(("127.0.0.1", 161)),
      "1.1",
      maxRows=3000, 
      ignoreNonIncreasingOid=False,
      lookupNames=False, 
      lookupValues=True)

From this nextCmd I would like to retrieve a table with the two OIDs I have set previously. Any help? Thanks!

Aucun commentaire:

Enregistrer un commentaire