I hope you can help me, The goal is to get the number of clients that have conected to the ap using pysnmp, I think I'm close, I know I have to use probably pyasn1, but I get to a part that gives me the following error:
('---------->', DisplayString('', subtypeSpec=ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(),ValueSizeConstraint(0, 255)),ValueSizeConstraint(0, 255))))
My code is this:
from pysnmp.hlapi import *
from pysnmp.proto import rfc1905
setcommunity = "public"
host = "192.168.1.51"
oid = '1.3.6.1.4.1.1.4.1.14179.2.1.1.1.38'
ssid = "Cisco1852i"
snmp_engine = SnmpEngine()
#this function gets the interface status of the cisco Switch
def show_apClients():
clients = nextCmd (snmp_engine,
CommunityData(setcommunity),
UdpTransportTarget((host, 161)),
ContextData(),
ObjectType(ObjectIdentity('SNMPv2-SMI', 'mib-2', '1.3.6.1.4.1.14179.2.1.1.1.38')))
errorIndication, errorStatus, errorIndex, varBinds = next(clients)
numberClients = varBinds[0][1]
print("----------->", numberClients)
return numberClients
nClients = show_apClients()
print(".....------->", nClients)
I think the OID, the MIB and the rest are all right, because I through the command:
"sudo snmpwalk.py -v 2c -c public 192.168.1.51 1.3.6.1.4.1.14179.2.1.4.1.7 | wc -l"
or
"sudo snmpwalk.py -v 2c -c public 192.168.1.51 1.3.6.1.4.1.14179.2.1.1.18" I can get the command line the number of clients