gpt4 book ai didi

python - pysnmp 将后缀附加到对象标识

转载 作者:行者123 更新时间:2023-12-01 09:00:31 25 4
gpt4 key购买 nike

我正在尝试利用 pysnmp 中的 setCmd() 方法来设置变量。我在设置特定对象标识时遇到问题,因为 pysnmp 似乎将“.0”附加到我想要设置的对象标识。为什么会发生这种情况?

我得到的输出是:

noSuchName at 1.3.6.1.4.1.2682.1.2.3.4.0

脚本内容为:

errorIndication, errorStatus, errorIndex, varBinds = next(
setCmd(SnmpEngine(),
CommunityData('dps_public', mpModel=0),
UdpTransportTarget(('192.168.1.100', 161)),
ContextData(),
ObjectType(ObjectIdentity('1.3.6.1.4.1.2682.1.2.3.4'),
Integer(2)))
)

if errorIndication:
print(errorIndication)
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'))
else:
for varBind in varBinds:
print(' = '.join([x.prettyPrint() for x in varBind]))

最佳答案

我怀疑您从 SNMP 代理获取了这个修改后的 OID(我认为这违反了协议(protocol))。据我所知,pysnmp 不应该以这种方式弄乱 OID。

要验证您可以在 demo.snmplabs.com 处针对 SNMP 代理尝试脚本。和/或启用 pysnmp 调试并查看来自您正在查询的 SNMP 代理的 PDU 中的内容。

from pysnmp import debug

debug.setLogger(debug.Debug('msgproc'))

...

关于python - pysnmp 将后缀附加到对象标识,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52488695/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com