I need to send snmp trap n number of host whenever any syslog is logged in /var/log/messages. How can I do this, can anybody give me any idea?

  • Depends on how complicated you're willing to go. you could look at something similar to the NAGIOS monitoring agents that can monitor and trap out when it picks something up. – Lawrence Mar 4 '14 at 12:54

If you use (or switch to) rsyslog, you can install the omsnmp module which can send syslog messages as SNMP traps.


LogZilla has the ability to send matched events from syslog to a trap receiver. You can download a demo from http://www.logzilla.net/index.php/download

To use the trap forwarding, login as admin and browse to Menu>Admin>Server Admin>Alerts and enable "Send Alerts to SNMP Trap Manager" and also set the SNMP Community and SNMP Destination values. Once you set those, HUP the syslog-ng daemon and enjoy :-)


inotify(7) is a system call that can be used to alert your process when the filesystem changes. inotifyd is a wrapper around inotify(). (inotifyd is in busybox but perhaps not in other distros.)

With inotifyd you make a script that does what you want, e.g. foo.sh

echo "inotifyd passed me event=$1 file=$2"

Then tell inotifyd to run your script whenever the syslog changes:

$ inotifyd ~/foo.sh /var/log/syslog:c
inotifyd passed me event=c file=/var/log/syslog
inotifyd passed me event=c file=/var/log/syslog
  • Can you expand on how one would do this? Perhaps adding an example? – slm Aug 13 '14 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.