 |
Your forum announcement here! |
|
 |

07-01-2007, 23:36
|
|
Senior System Administrator
|
|
Join Date: Oct 2006
Posts: 153
|
|
MySql monitoring script
Hi everyone!
Please use following script which will monitor MySQL Server service and will automatically restart it if its down.
Quote:
#!/bin/bash
# MySQL Server root/admin username
MUSER="root"
# MySQL Server admin/root password
MPASS="SET-ROOT-PASSWORD"
# MySQL Server hostname
MHOST="localhost"
#Shell script to start MySQL server i.e. path to MySQL daemon start/stop script.
MSTART="/etc/init.d/mysql start"
# Email ID to send notification
EMAILID="you@your-email.com"
# 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 "Error: MySQL Server is not running/responding ping request">>$MAILMESSAGE
echo "Hostname: $(hostname)" >>$MAILMESSAGE
echo "Date & 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="MySQL Server MySQL server successfully restarted"
else
sMess="MySQL server FAILED to restart"
fi
# Email status too
echo "Current Status: $sMess" >>$MAILMESSAGE
echo "" >>$MAILMESSAGE
echo "*** This email generated by $(basename $0) shell script ***" >>$MAILMESSAGE
echo "*** Please don't reply this email, this is just notification email ***" >>$MAILMESSAGE
# send email
$MAILCMD -s "MySQL server" $EMAILID < $MAILMESSAGE
else # MySQL is running and do nothing
:
fi
# remove file
rm -f $MAILMESSAGE
|
You just have to do some minor changes in this script (mysql password, email ID etc).
Then set a cron to run according to your requirement for the above script.
for eg.
Quote:
|
*/15 * * * * ./(path to script) > /dev/null 2>&1
|
This will run the script in every 15 mins.
That's all !!
Best Regards,
eUKShane
http://www.eukhost.com
|

05-04-2007, 11:21
|
|
Junior Member
|
|
Join Date: Feb 2007
Posts: 5
|
|
Hi Shane,
I have enabled monitoring of MySQL Server and httpd through my WHM - do you know if these will send email alerts as well, as your script seems to do?
thanks,
Iain
|

07-04-2007, 20:24
|
 |
Junior Member
|
|
Join Date: Oct 2006
Posts: 15
|
|
Hi Iain,
No, you will not receive any alert mails as the above mentioned script does.
But, you can also check the "CPU/Memory/MySQL" Usage from the WHM >> Server Status >> CPU/Memory/MySQL Usage and apache load from WHM >> Server Status >> Apache Status.
__________________
Best Regards,
Access Denied
|

24-04-2007, 18:41
|
|
Junior Member
|
|
Join Date: Apr 2007
Posts: 1
|
|
eUKShane can you confirm that the script really works?
|

01-05-2007, 04:11
|
|
Member
|
|
Join Date: Mar 2007
Posts: 65
|
|
may i ask, will that SQL Server query work on a database that is hosted by trap17,or will i have to edit it in any way?
|

01-05-2007, 11:58
|
 |
System Administrator
|
|
Join Date: Oct 2006
Posts: 214
|
|
Guys, I will suggest you to go for "System Integrity Monitor" which is best to monitor critical services, load, network etc on the server.
http://www.rfxnetworks.com/sim.php
|

28-05-2007, 19:37
|
|
new member
|
|
Join Date: Mar 2007
Posts: 4
|
|
Quote:
Originally Posted by eUKAlex
Guys, I will suggest you to go for "System Integrity Monitor" which is best to monitor critical services, load, network etc on the server.
http://www.rfxnetworks.com/sim.php
|
I've tried to install this on my VPS Hosting, but when I follow the instructions and run setup, nothing seems to appear in the default directories.
Is there any help available for installing this on an eUKHost VPS Hosting server?
Many thanks,
Darren.
|

28-05-2007, 20:23
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,997
|
|
Quote:
Originally Posted by darrenw
I've tried to install this on my VPS Hosting, but when I follow the instructions and run setup, nothing seems to appear in the default directories.
Is there any help available for installing this on an eUKHost VPS Hosting server?
Many thanks,
Darren.
|
I dont see any reason to install service monitoring scripts on cPanel VPS Hosting. cPanel has got its inbuilt service monitoring and chkservd will automatically restart any downed service. If you need sim even after knowing this then open a ticket for our VPS Hosting support team and they will install sim on your VPS Hosting.
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

28-05-2007, 20:31
|
|
new member
|
|
Join Date: Mar 2007
Posts: 4
|
|
Quote:
Originally Posted by eukhost.com
I dont see any reason to install service monitoring scripts on cPanel VPS Hosting. cPanel has got its inbuilt service monitoring and chkservd will automatically restart any downed service. If you need sim even after knowing this then open a ticket for our VPS Hosting support team and they will install sim on your VPS Hosting.
|
Hi,
For some reason, the MySQL service keeps intermittently failing for no apparent reason. How often does chkservd check downed services? Does it include mysql?
Many thanks,
Darren.
|

28-05-2007, 20:52
|
 |
Chief Marketing Officer
|
|
Join Date: Sep 2005
Posts: 4,997
|
|
chkservd checks status of services every minute so it will restart MySQL as soon as it goes down. There may be some other reason why MySQL fails and you need to question our support team about this problem.
none of our shared, reseller, semi-dedicated or dedicated hosting customers face this problem. This seems to happen on VPS Hosting's only as VPS Hosting seem to run short of memory for MySQL intensive website hostings. question our support team and find out the reason for this problem. It is possible that chkservd is down on your VPS Hosting 
__________________
UK Web Hosting || Business Hosting || eUKhost Knowledgebase
Toll Free : 0808 262 0255 || MSN : mark @ eukhost.com || AIM : eukmark
A bunch of Sheep led by a Lion is better than a bunch of Lions led by a Sheep.
__________________________________________________
Great Opportunity :: Join our Affiliate Program for FREE and earn 20% commission on each referral.
|

29-05-2007, 00:16
|
|
new member
|
|
Join Date: Mar 2007
Posts: 4
|
|
Quote:
Originally Posted by eukhost.com
chkservd checks status of services every minute so it will restart MySQL as soon as it goes down. There may be some other reason why MySQL fails and you need to question our support team about this problem. none of our shared, reseller, semi-dedicated or dedicated hosting customers face this problem. This seems to happen on VPS Hosting's only as VPS Hosting seem to run short of memory for MySQL intensive website hostings. question our support team and find out the reason for this problem. It is possible that chkservd is down on your VPS Hosting 
|
Unfortunately, MySQL Server has failed yet again for the third time in the last couple of days. The support ticket id is #DIT-48131-863
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT. The time now is 10:12.
|
|
|