#!/bin/sh
MailList="xxx@test.com"
DBDataDir="/usr/local/mysql/var"
DBPort="3306"
IP=`ifconfig | grep 'inet addr:' -m 1 | grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`;
ErrFile="$DBDataDir/$HOSTNAME.err"
ErrLine=`cat $ErrFile | wc -l`
GetDate=`date '+%Y-%m-%d %H:%M:%S'`
if [ ! -e /tmp/dberrline$DBPort ]
then
echo "$ErrLine" >/tmp/dberrline$DBPort
echo "Run it first!"
exit
fi
OldLine=`cat /tmp/dberrline$DBPort`
echo "$ErrLine" >/tmp/dberrline$DBPort
if [ "$ErrLine" -gt "$OldLine" ]
then
TailLine=`expr $ErrLine - $OldLine`
ErrStr=`tail -$TailLine "$ErrFile"`
LeftStr=`echo "$ErrStr" | sed '/InnoDB: ERROR: the age of the last checkpoint is/d' | sed '/InnoDB: which exceeds the log group capacity/d' |sed '/InnoDB: If you are using big BLOB or TEXT rows, you must set the/d' | sed '/InnoDB: combined size of log files at least 10 times bigger than the/d' | sed '/InnoDB: largest such row./d'`
if [ "$LeftStr" != "" ]
then
echo "$LeftStr" |mutt -s "Something wrong with $HOSTNAME-$IP($DBPort)!" ${MailList}
echo "$LeftStr"
fi
fi