Created
November 3, 2022 03:49
-
-
Save yujiterada/b30b8c0d6a0f44c4c6b02581d901b5ed to your computer and use it in GitHub Desktop.
SNMP Walk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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