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

时间:2022-05-31 04:00:52

I use python-netsnmpagent module. I've already used raw netsnmp library example which is on below link

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

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

This example can update tables and it work like a charm by below commands

此示例可以更新表,它通过以下命令像魅力一样工作

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"

but when I used the example of the python-netsnmpagent which is on below link

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

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

Update the entry of a table was shown me below error:

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

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" 

Is there anyone can help me?

有没有人可以帮助我?

1 个解决方案

#1


0  

Hi Ehsan Ahmadi

嗨Ehsan Ahmadi

You don't have write access to the table, because you did not enable this access when creating the table. Use this patch to enable this access.

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

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

GOOD LUCK

#1


0  

Hi Ehsan Ahmadi

嗨Ehsan Ahmadi

You don't have write access to the table, because you did not enable this access when creating the table. Use this patch to enable this access.

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

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

GOOD LUCK