Search code examples
luasnmpnet-snmp

use snmp in lua


Having a problem. I need to use snmpset in lua, so I use the luasnmp module.

When I tried that I get one error messages that say: "snmp: bad type (2) prim=0 in index 1"

But it is ok by using net-snmp snmpset by bash.

Has anybody any experience (or advice / where we should look) with this ? Thanks

Here is the script:

local snmp = require "snmp"

hub1, err = snmp.open{
  peer = "1.1.1.1", 
  community = "private", 
}
assert(hub1, err)

vbIn = {
  {oid = ".1.3.6.1.4.1.9.9.16.1.1.1.16.333", type = NUMBER, value = 6 },
}
vbOut, err = assert(hub1:set(vbIn))

Solution

  •  type = NUMBER
    

    seems strange. did you mean

     type = 'NUMBER'
    

    or

     type = snmp.NUMBER
    

    ? i guess print(NUMBER) will say 'nil'