This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

SNMP v1/v2c trap support
#1
New package with trap support: https://dl.openrb.com/lm-19-imx6/pkg/lua...4_imx6.ipk

Resident script (0 second sleep time). It binds to UDP port 162 and listens to incoming messages then parses them. snmp.parsetrap returns community name (string) and variable list (table) on success, nil plus error message otherwise.
Code:
if not sock then
  snmp = require('snmp')
  socket = require('socket')

  -- create UDP socket, listen on port 162
  sock = socket.udp()
  sock:setsockname('*', 162)
  sock:settimeout(1)
end

data, ip, port = sock:receivefrom()

-- incoming message
if data then
  -- parse message
  commres, vberr = snmp.parsetrap(data)

  -- valid message
  if commres then
    log(ip, commres, vberr)
  -- parse failed, see logs for more info
  else
    log('error', vberr)
  end
end
Reply


Messages In This Thread
SNMP v1/v2c trap support - by admin - 28.11.2019, 10:33
RE: SNMP v1/v2c trap support - by MarcusH - 20.02.2020, 12:58
RE: SNMP v1/v2c trap support - by Daniel - 20.02.2020, 13:17
RE: SNMP v1/v2c trap support - by MarcusH - 20.02.2020, 13:23
RE: SNMP v1/v2c trap support - by Daniel - 20.02.2020, 13:25
RE: SNMP v1/v2c trap support - by MarcusH - 20.02.2020, 13:30
RE: SNMP v1/v2c trap support - by admin - 20.02.2020, 13:32

Forum Jump: