diff options
author | elie <elie> | 2005-06-29 09:52:49 +0000 |
---|---|---|
committer | elie <elie> | 2005-06-29 09:52:49 +0000 |
commit | d4f00abeedb2c2c3064950345534919358787735 (patch) | |
tree | 7bc3fca40cf6a55321ac90aaf77281cbd264df20 | |
parent | 0e4753cd4acdb1c87d6d3fc004f7e0dd8325e1e4 (diff) | |
download | pysnmp-d4f00abeedb2c2c3064950345534919358787735.tar.gz |
files renamed for consistency
-rw-r--r-- | examples/v3arch/oneliner/manager/bulkgen.py | 22 | ||||
-rw-r--r-- | examples/v3arch/oneliner/manager/getgen.py | 19 | ||||
-rw-r--r-- | examples/v3arch/oneliner/manager/nextgen.py | 21 | ||||
-rw-r--r-- | examples/v3arch/oneliner/manager/withmib/nextgen.py | 44 |
4 files changed, 106 insertions, 0 deletions
diff --git a/examples/v3arch/oneliner/manager/bulkgen.py b/examples/v3arch/oneliner/manager/bulkgen.py new file mode 100644 index 0000000..045f398 --- /dev/null +++ b/examples/v3arch/oneliner/manager/bulkgen.py @@ -0,0 +1,22 @@ +from pysnmp.entity.rfc3413.oneliner import cmdgen + +errorIndication, errorStatus, errorIndex, \ + varBinds, varBindTable = cmdgen.CmdGen().bulkCmd( + # SNMP v2 +# cmdgen.CommunityData('test-agent', 'public'), + # SNMP v3 + cmdgen.UsmUserData('test-user', 'authkey1', 'privkey1'), + cmdgen.UdpTransportTarget(('localhost', 161)), + 0, 25, + (1,3,6,1,2,1,1) + ) + +if errorIndication: + print errorIndication +else: + if errorStatus: + print '%s at %s\n' % (errorStatus, varBinds[errorIndex-1]) + else: + for varBindTableRow in varBindTable: + for varBind in varBindTableRow: + print '%s = %s' % varBind diff --git a/examples/v3arch/oneliner/manager/getgen.py b/examples/v3arch/oneliner/manager/getgen.py new file mode 100644 index 0000000..d176e88 --- /dev/null +++ b/examples/v3arch/oneliner/manager/getgen.py @@ -0,0 +1,19 @@ +from pysnmp.entity.rfc3413.oneliner import cmdgen + +errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CmdGen().getCmd( + # SNMP v2 + cmdgen.CommunityData('test-agent', 'public'), + # SNMP v3 +# cmdgen.UsmUserData('test-user', 'authkey1', 'privkey1'), + cmdgen.UdpTransportTarget(('localhost', 161)), + (1,3,6,1,2,1,1,1,0) + ) + +if errorIndication: + print errorIndication +else: + if errorStatus: + print '%s at %s\n' % (errorStatus, varBinds[errorIndex-1]) + else: + for varBind in varBinds: + print '%s = %s' % varBind diff --git a/examples/v3arch/oneliner/manager/nextgen.py b/examples/v3arch/oneliner/manager/nextgen.py new file mode 100644 index 0000000..8ba61a9 --- /dev/null +++ b/examples/v3arch/oneliner/manager/nextgen.py @@ -0,0 +1,21 @@ +from pysnmp.entity.rfc3413.oneliner import cmdgen + +errorIndication, errorStatus, errorIndex, \ + varBinds, varBindTable = cmdgen.CmdGen().nextCmd( + # SNMP v2 + cmdgen.CommunityData('test-agent', 'public'), + # SNMP v3 +# cmdgen.UsmUserData('test-user', 'authkey1', 'privkey1'), + cmdgen.UdpTransportTarget(('localhost', 161)), + (1,3,6,1,2,1,1) + ) + +if errorIndication: + print errorIndication +else: + if errorStatus: + print '%s at %s\n' % (errorStatus, varBinds[errorIndex-1]) + else: + for varBindTableRow in varBindTable: + for varBind in varBindTableRow: + print '%s = %s' % varBind diff --git a/examples/v3arch/oneliner/manager/withmib/nextgen.py b/examples/v3arch/oneliner/manager/withmib/nextgen.py new file mode 100644 index 0000000..e5a0d1b --- /dev/null +++ b/examples/v3arch/oneliner/manager/withmib/nextgen.py @@ -0,0 +1,44 @@ +# SNMP GETNEXT with MIB resolution +import string +from pysnmp.entity.rfc3413.oneliner import cmdgen + +cmdGen = cmdgen.CmdGen() + +errorIndication, errorStatus, errorIndex, \ + varBinds, varBindTable = cmdGen.nextCmd( + # SNMP v1 +# cmdgen.CommunityData('test-agent', 'public', 0), + # SNMP v2 +# cmdgen.CommunityData('test-agent', 'public'), + # SNMP v3 + cmdgen.UsmUserData('test-user', 'authkey1', 'privkey1'), + cmdgen.UdpTransportTarget(('localhost', 161)), +# (('TCP-MIB', ''),), + (('SNMPv2-MIB', ''),), +# (('IP-MIB', ''),), +# (('IF-MIB', ''),), +# (('', 'interfaces'),), +# (1,3,6,1,2,1) +# (('','system'),) + ) + +if errorIndication: + print errorIndication +else: + if errorStatus: + print '%s at %s\n' % (errorStatus, varBinds[int(errorIndex)-1]) + else: + for varBindTableRow in varBindTable: + for varBind in varBindTableRow: + oid, val = varBind + (symName, modName), indices = cmdgen.mibvar.oidToInstanceName( + cmdGen.mibViewController, oid + ) + val = cmdgen.mibvar.cloneFromMibValue( + cmdGen.mibViewController, modName, symName, val + ) + print '%s::%s.%s = %s' % ( + modName, symName, + string.join(map(lambda v: v.prettyOut(v), indices), '.'), + val.prettyOut(val) + ) |