diff options
author | elie <elie> | 2005-06-17 14:24:51 +0000 |
---|---|---|
committer | elie <elie> | 2005-06-17 14:24:51 +0000 |
commit | 1b36e858ed76642f76a70169b10b9c98665027cd (patch) | |
tree | 93507c2e48deb10de9dca92edcdc22b3b70c216e /README | |
parent | fc6af3ee72b47d1df4d3281758fdf1c858ba8c36 (diff) | |
download | pysnmp-1b36e858ed76642f76a70169b10b9c98665027cd.tar.gz |
example updated
Diffstat (limited to 'README')
-rw-r--r-- | README | 21 |
1 files changed, 12 insertions, 9 deletions
@@ -67,26 +67,29 @@ protocol-oriented and, in particular, requires application to manage transport failures, access issues and so on. The second model supported by PySNMP resembles the SNMPv3 architecture, -as specified in [4]. Here is an example on querying an SNMP agent -for arbitrary value (sysDescr): +as specified in [4]. Here is an example on querying SNMP agent +for arbitrary value (sysDescr) over SNMP v3 with authentication and +privacy enabled: 8X---------------- cut here -------------------- from pysnmp.entity.rfc3413.oneliner import cmdgen -errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CmdGen().snmpGet( - cmdgen.UsmUserData('test-user', 'authkey1', 'privkey1'), - cmdgen.UdpTransportTarget(('localhost', 161)), - 'SNMPv2-MIB::sysDescr.0' +userData = cmdgen.UsmUserData('test-user', 'authkey1', 'privkey1') +targetAddr = cmdgen.UdpTransportTarget(('localhost', 161)) + +errorIndication, errorStatus, errorIndex, varBinds = cmdgen.CmdGen().getCmd( + userData, targetAddr, (('sysDescr', 'SNMPv2-MIB'), 0) ) -if errorIndication: +if errorIndication: # SNMP engine errors print errorIndication else: - if errorStatus: + if errorStatus: # SNMP agent errors print '%s at %s\n' % (errorStatus, varBinds[errorIndex-1]) else: - print varBinds + for varBind in varBinds: # SNMP agent values + print '%s = %s' % varBind 8X---------------- cut here -------------------- |