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
#2
Thanks admin. We will be testing it. Thank you
Reply
#3
Hi,

Im trying to use snmp to get information from an APC PDU 88xx series, but i don't fully understand the lua scipts for this function.
Could some one help me with this?
Reply
#4
Do you have anything in the logs?
------------------------------
Ctrl+F5
Reply
#5
I've tried some things and then i only get errors, but thats because i don't understand the script above since im not sure what I need to edit to connect to the device. If i only copy the script nothing appears in the logs
Reply
#6
From what I see the only thing you can change here is the UDP port.
------------------------------
Ctrl+F5
Reply
#7
Okey, so as far as i understand, this script will continusly listen on the 162 port for information.
Then it might be the PDU setup that is wrong and not sending the info to the logicmachine correctly
Reply
#8
This example is for SNMP traps (notifications). LM acts a server so you might need to adjust trap sending settings on your SNMP device.
What you probably need is to read/write data from SNMP device. See this thread for examples: https://forum.logicmachine.net/showthread.php?tid=1573
Reply


Forum Jump: