Skip to content

Instantly share code, notes, and snippets.

@bandit145
Created March 23, 2020 14:52
Show Gist options
  • Save bandit145/0b267678900d1bf189a5a93c99f7ed8b to your computer and use it in GitHub Desktop.
Save bandit145/0b267678900d1bf189a5a93c99f7ed8b to your computer and use it in GitHub Desktop.
import pysnmp.hlapi as pysnmp
COMMUNITY = pysnmp.CommunityData('data')
ADDRESS = ''
DATA = 'cdpCacheDeviceId'
table_results = pysnmp.nextCmd(pysnmp.SnmpEngine(), COMMUNITY, pysnmp.UdpTransportTarget((ADDRESS, 161)), pysnmp.ContextData(),
pysnmp.ObjectType(pysnmp.ObjectIdentity('CISCO-CDP-MIB', DATA)), lexicographicMode=False)
count = 0
for row in table_results:
print('Row: '+str(count))
for item in row:
if item:
print('\t'+str(item[0]))
count += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment