#!/bin/bash
#覧覧覧覧覧覧覧覧覧覧覧覧�
# Shell script to restart MySQL server if it is killed or not working
# due to ANY causes.
#覧覧覧覧覧覧覧覧覧覧覧覧�
# mysql root/admin username
MUSER=排oot�
# mysql admin/root password
MPASS=派ier passwort eintragen��
# mysql server hostname
MHOST=罵ocalhost�
#Shell script to start MySQL server i.e. path to MySQL daemon start/stop script.
# Debain uses following script, need to setup this according to your UNIX/Linux/BSD OS.
MSTART=�/etc/init.d/mysql start�
# Email ID to send notification
EMAILID=芭ustermann@test.de�
# path to mail program
MAILCMD=�$(which mail)�
# path mysqladmin
MADMIN=�$(which mysqladmin)�

#### DO NOT CHANGE anything BELOW ####
MAILMESSAGE=�/tmp/mysql.fail.$$�

# see if MySQL server is alive or not
# 2&1 could be better but i would like to keep it simple and easy to
# understand stuff
$MADMIN -h $MHOST -u $MUSER -p${MPASS} ping 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
echo 灯 >$MAILMESSAGE
echo 摘rror: MySQL Server is not running/responding ping request�>>$MAILMESSAGE
echo 滴ostname: $(hostname)� >>$MAILMESSAGE
echo 泥ate & Time: $(date)� >>$MAILMESSAGE
# try to start mysql
$MSTART>/dev/null
# see if it is started or not
o=$(ps cax | grep -c � mysqld$�)
if [ $o -eq 1 ]; then
sMess=熱ySQL Server MySQL server successfully restarted�
else
sMess=熱ySQL server FAILED to restart�
fi
# Email status too
echo 鼎urrent Status: $sMess� >>$MAILMESSAGE
echo 灯 >>$MAILMESSAGE
echo �*** This email generated by $(basename $0) shell script ***� >>$MAILMESSAGE
echo �*** Please don稚 reply this email, this is just notification email ***� >>$MAILMESSAGE
# send email
$MAILCMD -s 溺ySQL server� $EMAILID < $MAILMESSAGE
else # MySQL is running and do nothing
:
fi
# remove file
rm -f $MAILMESSAGE