def get_snmp_data(self):
Fetch mac addresses from WAP via SNMP.
devices = []
from pysnmp.entity.rfc3413.oneliner import cmdgen
oid="1.3.6.1.4.1.14988.1.1.1.2.1.1"
cmdGen = cmdgen.CommandGenerator()
errorIndication, errorStatus, errorIndex, varBindTable = cmdGen.nextCmd(
cmdgen.CommunityData( self.community ),
cmdgen.UdpTransportTarget( ( self.host , 161) ),
cmdgen.MibVariable( self.baseoid )
)
if errorIndication:
_LOGGER.exception( "SNMPLIB error: {}".format( errorIndication ) )
return
else:
if errorStatus:
_LOGGER.exception( "SNMP error: {} at {}".format( errorStatus.prettyPrint(), errorIndex and varBindTable[-1][int(errorIndex)-1] or "?" ) )
return
else:
for varBindTableRow in varBindTable:
for val in varBindTableRow.values():
devices.append( convertMac( val ) )
return devices
def convertMac(octect):
""" Convert a binary mac address to a string """