- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想重现以下 SNMP 命令的行为:
snmpwalk -v2c -cpublic 192.168.0.10 1.3.6.1.2.1.25.2.3.1.3
iso.3.6.1.2.1.25.2.3.1.3.1 = STRING: "Physical memory"
iso.3.6.1.2.1.25.2.3.1.3.3 = STRING: "Virtual memory"
iso.3.6.1.2.1.25.2.3.1.3.6 = STRING: "Memory buffers"
iso.3.6.1.2.1.25.2.3.1.3.7 = STRING: "Cached memory"
iso.3.6.1.2.1.25.2.3.1.3.8 = STRING: "Shared memory"
iso.3.6.1.2.1.25.2.3.1.3.10 = STRING: "Swap space"
iso.3.6.1.2.1.25.2.3.1.3.31 = STRING: "/"
iso.3.6.1.2.1.25.2.3.1.3.37 = STRING: "/run"
iso.3.6.1.2.1.25.2.3.1.3.39 = STRING: "/dev/shm"
iso.3.6.1.2.1.25.2.3.1.3.40 = STRING: "/run/lock"
iso.3.6.1.2.1.25.2.3.1.3.41 = STRING: "/sys/fs/cgroup"
iso.3.6.1.2.1.25.2.3.1.3.59 = STRING: "/tmp"
iso.3.6.1.2.1.25.2.3.1.3.60 = STRING: "/run/cgmanager/fs"
iso.3.6.1.2.1.25.2.3.1.3.61 = STRING: "/run/user/112"
iso.3.6.1.2.1.25.2.3.1.3.63 = STRING: "/run/user/0"
#!/usr/bin/env python3
from pysnmp.hlapi import *
def walk(host, oid):
for (errorIndication,errorStatus,errorIndex,varBinds) in nextCmd(SnmpEngine(),
CommunityData('public'), UdpTransportTarget((host, 161)), ContextData(),
ObjectType(ObjectIdentity(oid))):
if errorIndication:
print(errorIndication, file=sys.stderr)
break
elif errorStatus:
print('%s at %s' % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) - 1][0] or '?'),
file=sys.stderr)
break
else:
for varBind in varBinds:
print(varBind)
walk('192.168.0.10','1.3.6.1.2.1.25.2.3.1.3')
getCmd()
功能,但我无法让它按我想要的方式工作。
snmpwalk
来自我的 Python 代码的命令,但我更愿意使用 Python 模块找到解决方案。
最佳答案
尝试通过 lexicographicMode nextCmd()
的关键字参数.例如:
for (errorIndication,
errorStatus,
errorIndex,
varBinds) in nextCmd(SnmpEngine(),
CommunityData('public'),
UdpTransportTarget((host, 161)),
ContextData(),
ObjectType(ObjectIdentity(oid)),
lexicographicMode=False):
...
关于python-3.x - 使用 PySNMP 的 snmpwalk,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45000319/
我正在 Windows XP 机器上运行 Python 程序。当我运行该程序时,出现以下错误: File "C:\Python27\lib\pysnmp\smi\builder.pyt, line 2
我在 ubuntu 15.10 中安装了软件包及其依赖模块,但它仍然显示错误 从 pysnmp.hlapi 导入 *ImportError: 没有名为 hlapi 的模块 我尝试安装它sudo set
我想开发简单的 pysnmp 命令响应器来监听我的测试仪器设备,获取来自设备的请求,并在我的主机 PC(Ubuntu)中用我自己的命令(Telnet 命令)替换它们并将其发送到评估板。过去HOST上也
我正在尝试利用 pysnmp 中的 setCmd() 方法来设置变量。我在设置特定对象标识时遇到问题,因为 pysnmp 似乎将“.0”附加到我想要设置的对象标识。为什么会发生这种情况? 我得到的输出
为了获得更好的性能,我必须将我的 bash 脚本迁移到 python 脚本...所以我开始使用 pysnmp,但我遇到了有关输出格式的问题... 您将在下面找到 netsnmp 请求: snmpwal
如果我想并发执行pysnmp带有 cmdgen.CommandGenerator().nextCmd() 的线程,是 pysnmp线程安全? 当我测试它时,我没有看到表明有问题的问题;但是,我没有运行
我正在使用以下简单脚本: from pysnmp.entity.rfc3413.oneliner import cmdgen errorIndication, errorStatus, errorIn
我正在使用 PySNMP 作为 SNMP 代理来实现一个表。 我遵循使用自动生成的 TRS-MIB.py 文件和包含实现的手动编写的 __TRS-MIB.py 文件的(PySNMP 源)架构。 我已经
我刚开始使用 PYSNMP 协议(protocol),我正在尝试通过 SNMP 协议(protocol)从交换机断开和连接端口。我已经有一个与计算机通信的交换机,在本例中将是一个树莓派 3,但我需要一
我需要通过简单的 snmpget 查询询问 4000 台主机。我使用带线程的 netsnmp 和带扭曲的 pynetsnmp,它工作得非常快(不到 1 分钟)。我尝试将 pysnmp 与 AsyncC
我目前有一个脚本,可以使用 PySNMP 轮询多个设备上的多个 oid。它从文件中读取主机列表,对于某些主机需要轮询 3 或 4 个 oid,目前它是按顺序执行此操作,因此为了提高效率,我想做一个 g
我正在尝试将生成的 PYSNMP 数据存储到 mysql 数据库中。 生成的数据是元组还是列表——我不确定。 我得到的输出是 9016,但是当我希望将其保存到数据库时,它类似于 (OID(1.3.6.
我是Python新手。我正在尝试了解 pysnmp 的用法。 我尝试了以下方法: import asyncio from pysnmp.hlapi.asyncio import * from pysn
你好,我正在尝试使用 pysnmp 文档中的这段代码来监听陷阱: from pysnmp.carrier.asynsock.dispatch import AsynsockDispatcher fro
面对 pysnmp 代理返回值的奇怪问题。 PYSNMP 代理接收字符串格式为 "0a0a0a0a0a0a0a0a0a" . 在 MIB 中,OID 表示为 HEXA STRING。 当尝试使用 rf
我有一个想要返回的 SNMP OID 列表,但我无法用变量替换命令中的 OID。我什至尝试将变量包装在 eval 中,并与 ObjectType 和 ObjectIdentity 结合使用,但没有成功
我正在使用 python 2.7 并尝试使用 pysnmp 捕获 SNMP 陷阱。我正在使用 http://pysnmp.sourceforge.net/examples/current/v1arch
我正在尝试制作一个可以在 Pysnmp 中使用 IPv6 的程序,并且我已经从 google 等阅读了很多内容。 而且我总是发现人们使用Udp6SocketTransport。但问题是这个类不能在所有
我正在使用以下代码: import pysnmp from pysnmp.entity.rfc3413.oneliner import cmdgen errorIndication, errorSta
我正在尝试通过 SNMP 从 ucs-6100 获得答案。 通过控制台:(模拟我的请求) >>> snmpget -v3 -l authPriv -u usr-sha-aes -A authkey1
我是一名优秀的程序员,十分优秀!