diff options
Diffstat (limited to 'examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py')
-rw-r--r-- | examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py b/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py new file mode 100644 index 0000000..46c5ae4 --- /dev/null +++ b/examples/v3arch/oneliner/manager/cmdgen/getnext-v3-pull-whole-mib-with-mib-lookup.py @@ -0,0 +1,38 @@ +# +# Command Generator +# +# Send SNMP GETNEXT requests using the following options: +# +# * with SNMPv3, user 'usr-md5-none', MD5 authentication, no privacy +# * over IPv4/UDP +# * to an Agent at localhost:161 +# * for all OIDs in IF-MIB +# * stop when response OIDs leave the scopes of the table +# * perform response values resolution at MIB +# +# make sure IF-MIB.py is in search path +# +from pysnmp.entity.rfc3413.oneliner import cmdgen + +cmdGen = cmdgen.CommandGenerator() + +errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd( + cmdgen.UsmUserData('usr-md5-none', 'authkey1'), + cmdgen.UdpTransportTarget(('localhost', 161)), + cmdgen.MibVariable('IF-MIB', ''), + lookupValues=True +) + +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())) |