#!/bin/bash
##monitoring the mysql performance status ##
##created by jacobxian 20150114##
##script in /home/mysql/scripts/error_alert/error_alert.sh ##
##WORKPATH="/home/mysql/scripts/error_alert"
##mkdir -p ${WORKPATH}
#set -x
##start set environment
WORKPATH="/home/mysql/scripts/error_alert"
LOGPATH="/home/mysqlapp/mysqllog/logfile"
DATE=`date +"%Y%m%d"`
MAIL_LIST="xianyezhao@richinfo.cn"
MAIL_BIN="/home/crond/bsmtp"
MAIL_IP="192.168.219.34"
##end set environment
##sent mail slow log report for last day
my_sentmail()
{
echo " " | ${MAIL_BIN} -f `hostname`@139.com -h smtp.api.localdomain -s "${MAIL_IP}:Mysql Error Log Report " ${MAIL_LIST} < ${WORKPATH}/report/report_error_tail_${DATE}.log
}
##end sent mail slow log report for last day
##start monitor
cd ${LOGPATH}
ERROR_TIME=`stat mysql-err.log|grep Change`
ERROR_LASTTIME=`cat ${WORKPATH}/mysql_err_change_lasttime.log`
if [ "${ERROR_TIME}" != "${ERROR_LASTTIME}" ] ; then
tail -100 mysql-err.log >> ${WORKPATH}/report/report_error_tail_${DATE}.log
fi
##log current time to the log file
stat mysql-err.log|grep Change>${WORKPATH}/mysql_err_change_lasttime.log
##send error alert mail to dba
my_sentmail
##monitoring the mysql performance status ##
##created by jacobxian 20150114##
##script in /home/mysql/scripts/error_alert/error_alert.sh ##
##WORKPATH="/home/mysql/scripts/error_alert"
##mkdir -p ${WORKPATH}
#set -x
##start set environment
WORKPATH="/home/mysql/scripts/error_alert"
LOGPATH="/home/mysqlapp/mysqllog/logfile"
DATE=`date +"%Y%m%d"`
MAIL_LIST="xianyezhao@richinfo.cn"
MAIL_BIN="/home/crond/bsmtp"
MAIL_IP="192.168.219.34"
##end set environment
##sent mail slow log report for last day
my_sentmail()
{
echo " " | ${MAIL_BIN} -f `hostname`@139.com -h smtp.api.localdomain -s "${MAIL_IP}:Mysql Error Log Report " ${MAIL_LIST} < ${WORKPATH}/report/report_error_tail_${DATE}.log
}
##end sent mail slow log report for last day
##start monitor
cd ${LOGPATH}
ERROR_TIME=`stat mysql-err.log|grep Change`
ERROR_LASTTIME=`cat ${WORKPATH}/mysql_err_change_lasttime.log`
if [ "${ERROR_TIME}" != "${ERROR_LASTTIME}" ] ; then
tail -100 mysql-err.log >> ${WORKPATH}/report/report_error_tail_${DATE}.log
fi
##log current time to the log file
stat mysql-err.log|grep Change>${WORKPATH}/mysql_err_change_lasttime.log
##send error alert mail to dba
my_sentmail
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29114615/viewspace-1424391/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/29114615/viewspace-1424391/