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, 23:36
Senior System Administrator
 
Join Date: Oct 2006
Posts: 153
Thumbs up 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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 Server query work on a database that is hosted by trap17,or will i have to edit it in any way?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 01-05-2007, 11:58
eUK-Scott's Avatar
System Administrator
 
Join Date: Oct 2006
Posts: 214
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
Business Hosting || VPS Hosting || eUKhost Knowledgebase
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 28-05-2007, 20:23
eUKhost.com's Avatar
Chief Marketing Officer
 
Join Date: Sep 2005
Posts: 4,997
Send a message via AIM to eUKhost.com Send a message via MSN to eUKhost.com Send a message via Skype™ to eUKhost.com
Default

Quote:
Originally Posted by darrenw View Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 28-05-2007, 20:52
eUKhost.com's Avatar
Chief Marketing Officer
 
Join Date: Sep 2005
Posts: 4,997
Send a message via AIM to eUKhost.com Send a message via MSN to eUKhost.com Send a message via Skype™ 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 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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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 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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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

BB 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 10:12.

 

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

 
Site Map

VPS Hosting
VPS Hosting plans

Dedicated Server Hosting
Dedicated Server plans

Business Web Hosting
100% uptime Hosting

Cpanel Hosting
cPanel Shared Hosting

Reseller Hosting
Reseller Web Hosting

Windows Hosting
Windows Shared Hosting

Windows VPS

Windows VPS Hosting

Semi Dedicated Servers
Semi-Dedicated Hosting

Dedicated Server Mirroring
Dedicated Server Mirroring

Webhosting Knowledgebase
Frequently asked Questions

Web Hosting Blog
eUKhost Blog

Web Hosting Support
Support Helpdesk

UK Data Center
eUKhost Datacenter

Web Hosting Forum
eUKhost Forum

Support Tutorials
Online Flash Tutorials

Offsite Back-up Plans
Remote Backup Service

Customer Testimonials
eUK Customer Testimonials


knowledgebase articles

eUKhost.com Services

Pre-Sales Questions
Pre-sales FAQ's

Domain Names
Domain registration FAQ's

cPanel Hosting
cPanel Hosting FAQ's

Windows Web Hosting
Plesk Control Panel

Reseller Hosting
Reseller Hosting FAQ's

VPS Hosting
Virtual Private Server

Semi-Dedicated Servers
Semi-Dedicated FAQ's

Dedicated Servers
Dedicated Server Hosting


popular blog categories


Web Hosting
Website Hosting articles

UK Web Hosting
UK Hosting articles

Dedicated Server Hosting
Dedicated Server guidelines

VPS Hosting
VPS hosting articles

cPanel Hosting
cPanel Hosting articles

Linux Operating System
Linux Operating techniques

Windows Web Hosting
Windows plesk articles

Web Hosting
Web Hosting Service