问题标签 [pysnmp]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1703 浏览

python - pysnmp.smi.error.SmiError:未加载模块 X-MIB

我正在尝试对我的应用程序的一些特定 OID 执行 GET 命令。我有一个 .txt 格式的自定义 MIB 文件。我通过http://www.ibr.cs.tu-bs.de/projects/libsmi/tools/将文件转换为 .py 格式

我得到这个错误。我将输出保存为 X-MIB.py 并继续:

我将 X-MIB.py 文件保存在 C:\Python27\Lib\site-packages\pysnmp\smi\mibs 中。我知道这是不好的做法,但我只是想测试一下它是否有效。

这是我获取一些 OID 的脚本:

这是错误:

我的问题是如何解决这个错误?是不是因为之前制作X-MIB.py文件的时候出错了?

我知道它能够看到我的 X-MIB.py 文件,因为错误不是说“无法在路径中找到 X-MIB”或类似的东西。我阅读了http://pysnmp.sourceforge.net/上的文档,但我无法遵循它。

0 投票
1 回答
383 浏览

python - pysnmp:如何使 oid 可写

我想模拟一个 SNMP 设备,我没有来自设备的 MIB 文件。我只需要模拟一个函数,一个可写的 OctectString 值。

这是我的代码:

当我发送一个 snmp 写入值时,我得到了

从线

var reqPDU 内容:

谢谢。

0 投票
1 回答
2418 浏览

python - pysnmp: send hex string in trap

What I want is to send snmp traps just as the way that one of our network equipment do. The trap contains a name-value of DataTime and it's something like HEX String.

When I use snmptrap command of the net-snmp to send the trap, our Trap decoder can successfully parse the hex string to dateandtime format(YYYY-MM-HH hh:mm:ss) just like that it got a real trap from our Network equipment.

The command I use is like this:

x means that the string "07de07100a0c1e002b0800" is some kind of hex format.

When I try to use pysnmp to send complete the same task, our Trap decoder program do have received the trap but fail to parse the dateandtime. Here is the code that I use to send the trap, it's the official example of pysnmp, here.

I only modified the host and below part:

In order to figure out the differences, I captured the packages of sending traps that using snmptrap and pysnmp using WireShark, and here are the differences. Note that I am not using the same TRAP OID, but the phenomenon remain the same.

The first picture is that using snmptrap to send the trap, the other one is when using pysnmp. The Octet Strings are just different. Is anyone know why this happened? And how can I make it work to use pysnmp to send the trap in my situation? Thanks a lot in advance! When using snmptrap to send the trapWhen using pysnmp to send the trap

0 投票
1 回答
1643 浏览

python - 返回值 VarBinds pysnmp

我已经从自定义 MIB 制作了我的第一个 Python SNMP 代理。

它支持 SNMP GET 和 SET 请求,但它返回的值是我预先确定的。

如何使我的函数返回的 varbinds 成为用户通过其 SNMP SET 提供的值?

编码:

0 投票
2 回答
1346 浏览

python - pysnmp mac 到人类可读

我正在使用 pysnmp 从 ipNetToMediaPhysAddress 获取 IP 和 mac 地址列表这没有问题。我有一个问题,但是将 mac 地址转换为人类可读的地址。SNMP 代码导致 mac 显示为

我想知道如何将其转换为人类可读的 mac 地址。我知道根据此处的详细信息缺少一些 0 - http://blog.colovirt.com/2009/05/05/linuxnetworkingvmware-snmpwalk-mac-address-missing-0s/

是否有一些代码或使用 pysnmp 将其转换为人类可读的方法?

为你的帮助干杯

0 投票
1 回答
202 浏览

python - PySNMP 无法在 Ubuntu Precise 上发送带有 AES 加密的陷阱

我使用pysnmpPython lib 发送陷阱和snmptrap命令行工具接收,但是当我使用 AES 加密时客户端无法解析。

有趣的是,如果我使用 DES 或关闭加密,那么它就可以工作。如果我使用命令行工具发送 AES 加密陷阱,那么它也可以工作

这是使用的库的版本:

0 投票
1 回答
189 浏览

python - 如何使 pysmp oids 响应人类可读

我创建了一些 smnp 代理,它将使用 pysnmp 来获得 OID 的响应。如何使用 pysnmp 使响应 OID 对人类可读?

示例命令生成器:

感谢帮助!

0 投票
1 回答
322 浏览

python - 使用 PySNMP 难以掌握 MIB

我对 SNMP 协议相当陌生,最近才在我的计算机网络课程中介绍过它。

我了解经理如何发送 Gets、Sets、GetNext、GetBulk 和所有这些,它会捕获 Traps 等。我不完全理解的一件事是 MIB

据我所知,MIB 在代理上处于冷却状态,管理器将查询 MIB 树。这很好,尽管 Manager 需要 OID 才能正确查询。我关心的一个问题是这些是否是硬编码的。OID 是否在管理器中硬编码?

除此之外,我不确定如何构建 MIB 文件,显然有一些特殊的文件类型定义了 MIB 结构,我真的不知道如何使用 pySNMP 来构建它。我觉得我会在启动时在代理端运行它

有人可以帮我解决这些概念问题吗?

0 投票
1 回答
3976 浏览

python - 使用 pysnmp 从 MIB 文本约定转换 OID 值对

我正在尝试编写一段代码,它接受一个 JSON 对象,其中 OID 作为键,OID 值作为值。一个例子是:

收到此 JSON 对象后,我想使用 PySNMP 转换 OID 和 OID 值,但我不知道如何根据相应 MIB 文件中定义的文本约定转换 OID 值。

一个示例 MIB 文件将定义:

给定一个 OID 和一个遵循上述文本约定的 OID 值,我想翻译:

{"OID": 1,...}进入{"OID": true,...}

PySNMP 有可能吗?

0 投票
1 回答
850 浏览

python - PySNMP Short OID 错误尝试使用 MIB 文本约定翻译 OID

我正在使用问题Translate OID value pairs from MIB textual convention using pysnmp to translate OID and OID values based on MIB Textual Conventions 中描述的方法。

使用测试 OID 和测试 OID 值,我的代码如下:

当我运行我的代码时,出现以下错误:

文本约定如下:

对此错误的帮助将不胜感激!