Hi Gribouillis,
Thanks, I have modified code to work with snmpbulkwak with MAC address OID
1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.1
import re
from easysnmp import *
import time
start = time.time()
host = '10.124.115.10'
session = Session(hostname=host, community='wifi', version=2)
WLCip,SCGAPNumSta,SCGAPConnStatus,SCGAPDescription= (list(session.bulkwalk('1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.' + c ,non_repeaters=0, max_repetitions=50)) for c in ('1','10', '15', '16','22'))
for i in range(len(WLCip)):
mac_address = mac2norm(SCGAPMac[i].value)
print SCGAPMac[i].value
print mac_address
print ('{} {} {} {} {}'.format(host,mac_address,WLCip[i].value,SCGAPNumSta[i].value,SCGAPConnStatus[i].value,SCGAPDescription[i].value))
def mac2norm(mac):
return ('{}'.format(':'.join(a.split())))
if __name__ == "__main__":
main()
print('It took', time.time()-start, 'seconds.')
output of snmpwalk for MAC address oid is as
Output:
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.4.79.170.52.162.128 = Hex-STRING: 04 4F AA 34 A2 80
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.4.79.170.52.167.32 = Hex-STRING: 04 4F AA 34 A7 20
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.28.185.196.1.204.80 = Hex-STRING: 1C B9 C4 01 CC 50
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.28.185.196.1.233.176 = Hex-STRING: 1C B9 C4 01 E9 B0
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.28.185.196.3.121.112 = Hex-STRING: 1C B9 C4 03 79 70
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.28.185.196.3.122.160 = Hex-STRING: 1C B9 C4 03 7A A0
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.28.185.196.3.123.0 = Hex-STRING: 1C B9 C4 03 7B 00
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.28.185.196.3.124.16 = Hex-STRING: 1C B9 C4 03 7C 10
SNMPv2-SMI::enterprises.25053.1.3.2.1.1.2.2.1.1.6.28.185.196.3.125.128 = Hex-STRING: 1C B9 C4 03 7D 80
to convert mac to normal MAC, one function is used
Python 2.7.5 (default, Aug 4 2017, 00:39:18)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-16)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a = "04 4F AA 34 A2 80"
>>> print('{}'.format(':'.join(a.split())))
04:4F:AA:34:A2:80
and getting expected conversion.
but getting error post running this script
Error:
Traceback (most recent call last):
File "WLC.py", line 9, in <module>
WLCip,SCGAPNumSta,SCGAPConnStatus,SCGAPDescription= (list(session.bulkwalk('1.3.6.1.4.1.25053.1.3.2.1.1.2.2.1.' + c ,non_repeaters=0, max_repetitions=50)) for c in ('1','10', '15', '16','22'))
ValueError: too many values to unpack