MariaDBのサービス起動チェック
#!/bin/sh
## -------------------------------------------------------------------------
## Script Name :
## Created by : T.Naritomi
## on : 2009.11.26
## Updated by :
## on :
## Parameters :
## Return Code : 0=Normal End
## Comments :
## -------------------------------------------------------------------------
## ---detail----------------------------------------------------------------
CHECK_HOST=localhost
RESLOG=/tmp/$$.txt
TMP_FILE=/tmp/$$TMP.txt
MAIL_TO=hogehoge@gavann-it.com
MAIL_TITLE="auto)mysql response error nariDB on "${CHECK_HOST}
##------Check by mysql ---------------------------------------
/usr/bin/mysql -h ${CHECK_HOST} -u nari -pXXX >> ${RESLOG} << _EOF
show databases ;
exit
_EOF
cat ${RESLOG}
RES=`cat ${RESLOG} | grep nariDB_1st | wc -l`
echo response=${RES}
if [ $RES -ne 0 ] ; then
echo ok
else
echo mysql response error
echo "down node = nariDB " ${CHECK_HOST} >> ${TMP_FILE}
/bin/mail -s "$MAIL_TITLE" $MAIL_TO < ${TMP_FILE}
fi
##------ rm execute --------------------------------------
rm -f ${RESLOG}
rm -f ${TMP_FILE}
exit $?
crontab登録内容
#Timely procdure
00,10,20,30,40,50 * * * * sync
08,18,28,38,48,58 6-21 * * * /bin/sh /gvis/script/504_nariDBcheck.sh > /dev/null