snmp-cmds and pysnmp examples

snmp-cmds example

from snmp_cmds import snmpwalk

res = snmpwalk(
    ipaddress='10.1.1.1',
    oid='1.3.6.1.4.1.9.9.618.1.4.1.0',
    community='public')

print(res)

pysnmp example

from pysnmp.hlapi import *

g = getCmd(
    SnmpEngine(), CommunityData('public'), UdpTransportTarget(
        ('10.1.1.1', 161)), ContextData(), ObjectType(
            ObjectIdentity('1.3.6.1.4.1.9.9.618.1.4.1.0')))

errorIndication, errorStatus, errorIndex, varBinds = next(g)

for varBind in varBinds:
    print(' = '.join([x.prettyPrint() for x in varBind]))

Leave a Reply

Your email address will not be published.