Sophie

Sophie

distrib > PLD > ac > amd64 > media > dist > by-pkgid > 1df0730b8e8191c3cf19634634b3265e > files > 25

python-pysnmp-examples-4.1.3a-1.noarch.rpm

from pysnmp.entity.rfc3413.oneliner import cmdgen

errorIndication, errorStatus, \
                 errorIndex, varBinds = cmdgen.CommandGenerator().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