I have been given a task to generate SNMP data for printers in a network. I have been able to generate data using snmpwalk in pyscripter.
However i wish to know how to implement the same and display on the web using Django.
This is similar to NMS systems.
The code i am using to generate SNMP data is
from pysnmp.entity.rfc3413.oneliner import cmdgen
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
cmdgen.CommunityData('public'),
cmdgen.UdpTransportTarget(('192.168.1.101', 161)),
'1.3.6.1.2.1.2.2.1',
)
if errorIndication:
print(errorIndication)
else:
if errorStatus:
print('%s at %s' % (
errorStatus.prettyPrint(),
errorIndex and varBindTable[-1][int(errorIndex)-1] or '?'
))
else:
for varBindTableRow in varBindTable:
for name, val in varBindTableRow:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))