33 lines
903 B
Bash
33 lines
903 B
Bash
#!/bin/bash
|
|
#Script to analyze and optimize all databases on a server
|
|
|
|
HOSTNAME=`hostname`
|
|
MYSQLCHECK_CMD=`which mysqlcheck`
|
|
MAIL_CMD=`which mail`
|
|
CAT_CMD=`which cat`
|
|
DIRNAME_CMD=`which dirname`
|
|
BASENAME_CMD=`which basename`
|
|
#EGMC_ROOT=`$DIRNAME_CMD $0`
|
|
#EGMC_SCRIPT=`$BASENAME_CMD $0`
|
|
CONF_FILE="egmysqloptimize.conf"
|
|
MYSQLCHECK_OPTS="-Aaosv"
|
|
|
|
if [ -e $CONF_FILE ] ; then
|
|
. $CONF_FILE
|
|
fi
|
|
echo "Starting MYSQL Check on all Databases" >> $LOGFILE
|
|
echo "*************************************" >> $LOGFILE
|
|
|
|
if ! $MYSQLCHECK_CMD $MYSQLCHECK_OPTS -u $MYSQL_USER --password=$MYSQL_PASS >> $LOGFILE ; then
|
|
echo "Error, mysql check returned $?" >> $LOGFILE
|
|
CHECK_STATUS="[ERROR]"
|
|
else
|
|
echo "Mysqlcheck ran successfully"
|
|
CHECK_STATUS="[SUCCESS]"
|
|
fi
|
|
|
|
$CAT_CMD $LOGFILE | $MAIL_CMD -s "$CHECK_STATUS Mysqlcheck for $HOSTNAME" $EMAILTO >> $LOGFILE 2 >> $LOGFILE
|
|
echo "Emails send to $EMAILTO" >> $LOGFILE
|
|
|
|
|
|
|