me@workstation:~$ crontab -l */5 * * * * /bin/sh /home/me/code/shell/monitor.sh > /dev/null 2>&1 me@workstation:~$ cat /home/me/code/shell/monitor.sh #!/bin/sh EMAIL="my_number@cell_phone_company.com"; HOST="mailserver.domain.tld"; PORTS="25,80,110,143,443,587,993,995"; CMD=`/usr/bin/nmap -p $PORTS $HOST | grep tcp | grep -v open`; if [ -n "$CMD" ] # if output of command has non-zero length then echo $CMD | /bin/mail $EMAIL; else echo "$PORTS are open on $HOST"; fi me@workstation:~$
Thursday, October 25, 2007
five-minute monitoring
A system independent of my mail server will text my phone if any of the ports on the mail server are not accessible. It checks every 5 minutes, which is about how long it took to whip this thing up.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment