Thursday, April 11, 2013

Multiple tail via ssh

I just wrote simple script to remotely monitor logs of many servers and log files and display on screen with colors depends on event. You can also add parameter to receive emails when event occurs.

Script will automatically login into server via ssh and start tail.

Another great tool CHIP 

Also I use sshpass for automatic login (for security reason you can write password in separate file)

#!/bin/bash
sleep 120 &
pid="$!"
sleep 120 &
pid="$pid $!"
echo "my process pid is: $$"
echo "my child pid list is: $pid"

/usr/bin/sshpass -p PASSWORD /usr/local/bin/chip -f -m2='LOG-EVENT-1' -s2='YELLOW on_blue' -m3='LOG-EVENT-2' -s3='WHITE' -s1 [email protected]:'/var/log/LOGFILE'

/usr/bin/sshpass -p PASSWORD /usr/local/bin/chip -f -m2='LOG-EVENT-1' -s2='YELLOW on_blue' -m3='LOG-EVENT-2' -s3='WHITE' -s1 [email protected]:'/var/log/LOGFILE'

trap 'echo I am going down, so killing my processes..; kill $pid; exit' SIGHUP SIGINT  SIGQUIT SIGTERM

No comments:

Post a Comment

Cybermap

Internet Storm Center Infocon Status

Internet Storm Center Infocon Status
Internet Storm Center Infocon Status