我使用 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"
有没有人可以帮助我?
最佳答案
您没有对表的写入权限,因为您在创建表时没有启用此权限。使用此补丁启用此访问权限。
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/