I am trying to implement a snmp agent with two different context name.I got some sample program from the http://snmplabs.com/ . Following is how I am trying to implement my agent side. At the begining of the implementation I got some error like
Error: OID not increasing: SNMPv2-SMI::dod
>= SNMPv2-SMI::dod
I got answer from the stackoverflow for that.
Error: OID not increasing: SNMPv2-SMI::dod, How to increase OID?
So I fixed my code like
class sample ():
def readVars (self , varBinds, acInfo=(None, None)):
retItem = []
for ov in varBinds:
if str(ov[0]) == '1.3.6.1.4.1.12345.1.1.1.0':
retItem.extend([(ov[0], v2c.OctetString('%s' % primary_keys['value1']))])
elif str(ov[0]) == '1.3.6.1.4.1.12345.1.1.2.0':
retItem.extend([(ov[0], v2c.OctetString('%s' % primary_keys['value2']))])
.
.
.
.
def readNextVars (self , varBinds, acInfo=(None, None)):
retItem = []
for ov in varBinds:
if str(ov[0]) == '1.3.6.1.4.1.12345.1.1.1.0':
retItem.extend([('1.3.6.1.4.1.12345.1.1.2.0', v2c.OctetString('%s' % primary_keys['value2']))])
elif str(ov[0]) == '1.3.6.1.4.1.12345.1.1.2.0':
retItem.extend([('1.3.6.1.4.1.12345.1.1.3.1.1.0', v2c.OctetString('%s' % item_list['value3']]))])
.
.
.
.
else:
retItem.extend([('1.3.6.1.4.1.44555.1.1.1.0', v2c.OctetString('%s' % primary_keys['value1']))])
return retItem
and I registred this class under the context like this
mibTreeA = sample()
self._snmpContext.registerContextName(v2c.OctetString('ContextOne'), mibTreeA)
self._snmpContext.registerContextName(v2c.OctetString('ContextTwo'), mibTreeA)
But the problem is I want to use more than 50 OIDs in this, so I am thinking to make it dynamic, any suggestion or example for doing that. Please ask if you want more details.