プロセスを監視する簡易スクリプトです。
vim process_check.sh ------------- #!/bin/sh processName=$1 if [ "$processName" = "" ]; then echo "usage: $0 {process name}" exit 0 fi PROC_NUM=`ps -ef | grep $processName | grep -v grep | grep -v $0 | wc -l` if [ $PROC_NUM -ne 0 ]; then exit 0 fi echo "process: $processName not found , send alert" email=___email___ domain=___domain___ Subject="$domain NG PROCESS_CHECK" ( cat << EOF process check failed to $processName please check $domain EOF ) | /bin/mail -s "$Subject" ${email} -------------
プロセス名を指定して使います
sh process_check.sh mysqld