Skip to content

Instantly share code, notes, and snippets.

@yujiterada
Created November 3, 2022 03:49
Show Gist options
  • Save yujiterada/b30b8c0d6a0f44c4c6b02581d901b5ed to your computer and use it in GitHub Desktop.
Save yujiterada/b30b8c0d6a0f44c4c6b02581d901b5ed to your computer and use it in GitHub Desktop.
SNMP Walk
from pysnmp.hlapi import *
V2_COMMUNITY = 'meraki-rw'
MERAKI_DEVICE = '192.168.128.108'
iterator = nextCmd(
SnmpEngine(),
CommunityData(V2_COMMUNITY),
UdpTransportTarget((MERAKI_DEVICE, 161)),
ContextData(),
ObjectType(ObjectIdentity('IF-MIB'))
)
for errorIndication, errorStatus, errorIndex, varBinds in iterator:
if errorIndication:
print(errorIndication)
break
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
break
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment