【问题标题】:Cannot update table entry in python-netsnmpagent无法更新 python-netsnmpagent 中的表条目
【发布时间】:2018-11-26 09:38:44
【问题描述】:

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

有人可以帮助我吗?

【问题讨论】:

  • 拜托,为什么是 C 标签?
  • 因为 python-netsnmpagent 模块是 netsnmp 的 C 库的包装器。我认为这个问题源于 c 包装器。
  • 好吧,那么一切不都是一些 C 东西的包装吗? ;-)
  • 也许是的,但一切都不是 net-snmp c 库的包装器。 ;-)

标签: python c snmp agent net-snmp


【解决方案1】:

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

祝你好运

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2016-05-16
    • 2023-03-03
    • 1970-01-01
    • 1970-01-01
    • 2013-08-02
    相关资源
    最近更新 更多