UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  UK Web Hosting | Dedicated Server Windows and Linux VPS Forum > Web Hosting and Domains > MySQL Hosting

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-01-2007, 22:36
Senior System Administrator
 
Join Date: Oct 2006
Posts: 145
Thumbs up MySql monitoring script

Hi everyone!

Please use following script which will monitor mysql service and will automatically restart it if its down.

Quote:
#!/bin/bash

# mysql root/admin username
MUSER="root"

# mysql 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
Reply With Quote
  #2 (permalink)  
Old 05-04-2007, 11:21
Junior Member
 
Join Date: Feb 2007
Posts: 5
Default

Hi Shane,

I have enabled monitoring of mysql and httpd through my WHM - do you know if these will send email alerts as well, as your script seems to do?

thanks,
Iain
Reply With Quote
  #3 (permalink)  
Old 07-04-2007, 20:24
Access Denied's Avatar
Junior Member
 
Join Date: Oct 2006
Posts: 15
Default

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
Reply With Quote
  #4 (permalink)  
Old 24-04-2007, 18:41
Junior Member
 
Join Date: Apr 2007
Posts: 1
Default

eUKShane can you confirm that the script really works?
Reply With Quote
  #5 (permalink)  
Old 01-05-2007, 04:11
Member
 
Join Date: Mar 2007
Posts: 65
Default

may i ask, will that sql query work on a database that is hosted by trap17,or will i have to edit it in any way?
Reply With Quote
  #6 (permalink)  
Old 01-05-2007, 11:58
eUK-Scott's Avatar
System Administrator
 
Join Date: Oct 2006
Posts: 192
Wink

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
__________________

Best Regards,
eUKScott
VPS Hosting || Managed Hosting
Reply With Quote
  #7 (permalink)  
Old 28-05-2007, 19:37
new member
 
Join Date: Mar 2007
Posts: 4
Default

Quote:
Originally Posted by eUKAlex View Post
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, 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 server?

Many thanks,
Darren.
Reply With Quote
  #8 (permalink)  
Old 28-05-2007, 20:23
eUKhost.com's Avatar
Chief Marketing Officer
 
Join Date: Sep 2005
Posts: 4,253
Send a message via AIM to eUKhost.com Send a message via MSN to eUKhost.com
Default

Quote:
Originally Posted by darrenw View Post
I've tried to install this on my VPS, 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 server?

Many thanks,
Darren.
I dont see any reason to install service monitoring scripts on cPanel VPS. 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 support team and they will install sim on your VPS.
__________________
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.
Reply With Quote
  #9 (permalink)  
Old 28-05-2007, 20:31
new member
 
Join Date: Mar 2007
Posts: 4
Default

Quote:
Originally Posted by eukhost.com View Post
I dont see any reason to install service monitoring scripts on cPanel VPS. 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 support team and they will install sim on your VPS.
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.
Reply With Quote
  #10 (permalink)  
Old 28-05-2007, 20:52
eUKhost.com's Avatar
Chief Marketing Officer
 
Join Date: Sep 2005
Posts: 4,253
Send a message via AIM to eUKhost.com Send a message via MSN to eUKhost.com
Default

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's only as VPS seem to run short of memory for MySQL intensive websites. question our support team and find out the reason for this problem. It is possible that chkservd is down on your VPS
__________________
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.
Reply With Quote
  #11 (permalink)  
Old 29-05-2007, 00:16
new member
 
Join Date: Mar 2007
Posts: 4
Default

Quote:
Originally Posted by eukhost.com View Post
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's only as VPS seem to run short of memory for MySQL intensive websites. question our support team and find out the reason for this problem. It is possible that chkservd is down on your VPS
Unfortunately, mysql has failed yet again for the third time in the last couple of days. The support ticket id is #DIT-48131-863
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 03:03.

 

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by Web Hosting 3.1.0
Copyright © 2001-2008, eUKhost.com. All rights reserved.

 
Site Map

knowledgebase articles

popular blog categories