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 whether you accept or reject these cookies being set.

SNMP v1/v2c trap support
#1
New package with trap support: http://dl.openrb.com/lm-19-imx6/pkg/luas...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
#2
Thanks admin. We will be testing it. Thank you
Reply


Forum Jump: