Search code examples
pythoncsnmpagentnet-snmp

Cannot update table entry in python-netsnmpagent


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

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

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?


Solution

  • Hi 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