无法更新pythonnetsnmpagen中的表项

2024-09-28 23:18:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用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" 

有人能帮我吗?你知道吗


Tags: httpsgithubtxtcomstringnet链接my
1条回答
网友
1楼 · 发布于 2024-09-28 23:18:45

你好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

祝你好运

相关问题 更多 >