python - 无法更新 python-netsnmpagent 中的表条目

标签 python c snmp agent net-snmp

我使用 python-netsnmpagent 模块。我已经使用了下面链接中的原始 netsnmp 库示例

https://github.com/circonus-labs/net-snmp/blob/master/mibs/NET-SNMP-EXAMPLES-MIB.txt

这个例子可以更新表格,它通过下面的命令非常有效

snmpwalk  -v 2c -c public -mPATH/TO/MY-MIB/MY-NET-SNMP-EXAMPLES-MIB.txt localhost:5555 netSnmpIETFWGTable
NET-SNMP-EXAMPLES-MIB::nsIETFWGChair1."snmpv3" = STRING: "string1"
NET-SNMP-EXAMPLES-MIB::nsIETFWGChair2."snmpv3" = STRING: "string2"

但是当我使用下面链接中的 python-netsnmpagent 示例时

https://github.com/pief/python-netsnmpagent/blob/master/examples/run_simple_agent.sh

更新表的条目显示如下错误:

snmpset -v 2c -c simple -mPATH/TO/MY-MIB/MY-NET-SNMP-EXAMPLES-MIB.txt localhost:5555 MY-NET-SNMP-EXAMPLES-MIB::nsIETFWGChair1.\"snmpv3\" s "STRING"
 Error in packet.
 Reason: notWritable (That object does not support modification)
 Failed object: MY-NET-SNMP-EXAMPLES-MIB::nsIETFWGChair1."snmpv3" 

有没有人可以帮助我?

最佳答案

Ehsan Ahmadi

您没有对表的写入权限,因为您在创建表时没有启用此权限。使用此补丁启用此访问权限。

diff --git a/examples/simple_agent.py b/examples/simple_agent.py
index ba809ff..abbfa53 100755
--- a/examples/simple_agent.py
+++ b/examples/simple_agent.py
@@ -143,12 +143,13 @@ firstTable = agent.Table(
        agent.DisplayString()
    ],
    columns = [
-       (2, agent.DisplayString("Unknown place")),
-       (3, agent.Integer32(0))
+       (2, agent.DisplayString("Unknown place"), 1),
+       (3, agent.Integer32(0), 1)
    ],
    counterobj = agent.Unsigned32(
        oidstr = "SIMPLE-MIB::firstTableNumber"
-   )
+   ),
+        extendable = True
 )

 # Add the first table row

祝你好运

关于python - 无法更新 python-netsnmpagent 中的表条目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50894258/

相关文章:

linux - 如何使用 MIB 文件从 Linux 命令行发送陷阱

azure - SNMP 与 MS Azure 存储

python - Pandas 是否有一种 Pythonic 方式将新的分层列添加到平面列 Dataframe

python - 在Python中动态构建 "array of strcuts"

c - echo $PATH in system() 给我一个错误的输出

c - string.h 包含对代码的影响

snmp - 如何从 net-snmp 创建 snmp 代理

python - 优化嵌套 for 循环

python - 条件变量初始化的pythonic方式是什么?

c - BST 插入不工作