ds_agentとds_amのプロセス数を監視します。
#!/bin/sh DOMAIN={domain} RCPT={email} CHECK_FILE=/tmp/.tmp_ds SCRIPT_PATH=`echo $(cd $(dirname $0);pwd)` function check_ds() { ds_am_result=`ps aux | grep ds_am | grep -v grep | wc -l` ds_agent_result=`ps aux | grep ds_agent | grep -v grep | grep -v ds_am | wc -l` if [ $ds_am_result -eq 0 -o $ds_agent_result -eq 0 ]; then # fail echo 1 else # success echo 0 fi } function send_alert() { SUBJECT="$DOMAIN NG DeepSecurity Process" ( cat << EOF $DOMAIN DeepSecurity Process Failed please check ds_agent and ds_am process in $DOMAIN EOF ) | mail -s "$SUBJECT" $RCPT } function send_recover() { SUBJECT="$DOMAIN OK DeepSecurity Process" ( cat << EOF $DOMAIN DeepSecurity Process Recovered EOF ) | mail -s "$SUBJECT" $RCPT } function create_tmp() { touch $CHECK_FILE } function remove_tmp() { rm -f $CHECK_FILE } function is_exists_tmp() { if [ -f $CHECK_FILE ]; then echo 0 else echo 1 fi } if [ "$1" = "mailtest" ]; then send_alert exit 0 fi if [ `check_ds` -eq 1 ]; then if [ `is_exists_tmp` -eq 1 ]; then send_alert create_tmp fi else if [ `is_exists_tmp` -eq 0 ]; then send_recover remove_tmp fi fi