#!/bin/bash # Bash Script on 7/06/2001 by Barry Grussling # # Basically, this script check for each process in the PROCS directive # and sends an email if the process has been down for 5 min to $EMAIL. It # sends a repeat page every 30 minutes. # # # Note, if you remove a process from $PROCS, please ensure all /tmp/.*$PROC* # files are removed. PROCS="syslogd klogd sshd inetd smbd nmbd named dhcpd mysqld nfsd master" EMAIL="user@host.com" scanproc() { if [ -z "$(ps -ax | grep $1 | grep -v grep)" ] then if [ -e /tmp/.no.$1 ]; then if [ -n "$(find /tmp/.no.$1 -mmin +5 -print)" ]; then if [ -e /tmp/.paged.$1 ]; then if [ -n "$(find /tmp/.paged.$1 -mmin +30 -print)" ]; then rm -f /tmp/.paged.$1 fi else echo HEADS UP, $1 is out on `hostname` . | mail -s "$1 NOT RUNNING" $EMAIL touch /tmp/.paged.$1 fi fi else touch /tmp/.no.$1 fi else rm -f /tmp/.no.$1 rm -f /tmp/.paged.$1 fi } for proc in $PROCS; do scanproc $proc done