Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
18 lines (16 sloc) 670 Bytes
from pysnmp.entity.rfc3413.oneliner import cmdgen
snmpCmdGen = cmdgen.CommandGenerator()
snmpTransportData = cmdgen.UdpTransportTarget(('localhost', 161))
error, errorStatus, errorIndex, binds = snmpCmdGen.getCmd(cmdgen.CommunityData("public"), snmpTransportData, "1.3.6.1.2.1.1.1.0", "1.3.6.1.2.1.1.3.0", "1.3.6.1.2.1.2.1.0")
if error:
print "Error "+error
else:
if errorStatus:
print('%s at %s' % (
errorStatus.prettyPrint(),
errorIndex and binds[int(errorIndex)-1] or '?'
)
)
else:
for name, val in binds:
print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))