【发布时间】:2018-02-07 10:21:01
【问题描述】:
我希望你能帮助我, 目标是获取使用 pysnmp 连接到 ap 的客户端数量,我想我已经接近了,我知道我可能必须使用 pyasn1,但我得到了一个给我以下错误的部分:
('---------->', DisplayString('', subtypeSpec=ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(ConstraintsIntersection(),ValueSizeConstraint(0, 255)),ValueSizeConstraint(0,第255章))))
我的代码是这样的:
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)
我认为OID、MIB等都可以,因为我通过命令:
“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”
或
“sudo snmpwalk.py -v 2c -c public 192.168.1.51 1.3.6.1.4.1.14179.2.1.1.18” 我可以在命令行获取客户端的数量
【问题讨论】:
标签: python linux snmp pysnmp pyasn1