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?
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
inotifyd is in busybox but perhaps not in other distros.)
inotifyd you make a script that does what you want, e.g.
#!/bin/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 ...