pysnmp.sourceforge.net
HOME QUICK START DOCUMENTATION EXAMPLES DOWNLOAD
DEVELOPMENT | CONTACT |

SNMP v1:

GET
SET with multiple values
GETNEXT
GETNEXT with custom MIB location

SNMP v2c:

GET
GET with custom timeout & retries
SET with MIB lookup
GETNEXT
GETNEXT with MIB resolution
GETBULK

SNMP v3:

GET with MIB lookup
GET over IPv6
GET table object by index
GET table object by multiple indices
SET with MIB lookup
SET with custom SNMP Engine ID
SET with custom ContextEngineID and ContextName
GETNEXT over IPv6
GETNEXT, pulling whole MIB
GETNEXT with options
GETBULK over IPv6
GETBULK with options

Asynchronous SNMP:

GET with multiple transports and protocols
GETNEXT with multiple transports and protocols
GET with multiple SNMP engines

Multithreaded SNMP:

GET with multiple transports and protocols

WARNING: you are reading historical documentation! Please, refer here.

GET Command Generator Application

Perform SNMP GET operation with the following options:

This script performs similar to the following Net-SNMP command:

$ snmpget -v2c -c public -ObentU demo.snmplabs.com 1.3.6.1.2.1.1.1.0 1.3.6.1.2.1.1.6.0

from pysnmp.entity.rfc3413.oneliner import cmdgen

cmdGen = cmdgen.CommandGenerator()

errorIndication, errorStatus, errorIndex, varBinds = cmdGen.getCmd(
    cmdgen.CommunityData('public'),
    cmdgen.UdpTransportTarget(('demo.snmplabs.com', 161)),
    '1.3.6.1.2.1.1.1.0',
    '1.3.6.1.2.1.1.6.0'
)

# Check for errors and print out results
if errorIndication:
    print(errorIndication)
else:
    if errorStatus:
        print('%s at %s' % (
            errorStatus.prettyPrint(),
            errorIndex and varBinds[int(errorIndex)-1] or '?'
            )
        )
    else:
        for name, val in varBinds:
            print('%s = %s' % (name.prettyPrint(), val.prettyPrint()))

To download this example as a Python file, please click here.


Need help? Try PySNMP mailing lists or report to library maintainers.
SourceForge Logo