Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

Possible Duplicate:
Services to monitor and report if a web site goes down?

I've had an interesting day. I've been with a hosting company for 8+ years without a hitch. Today the MySQL on my server failed without any real reason. I had no idea so my site was down for 3 hours and of course I got emails from customers wondering what had happened. Not fun.

What are ways to ensure my site is always live? It would be great if I got a text message saying it's down. Are there any practical things that one should do to ensure their site is performing?

share|improve this question

migrated from stackoverflow.com May 28 '12 at 12:03

This question came from our site for professional and enthusiast programmers.

marked as duplicate by John Conde May 28 '12 at 17:07

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3  
Get a website monitoring account, such as one from pingdom.com (there are loads of such firms, some of them free). Some will send you an SMS if the service is down, which is good for speedy notification. –  halfer May 27 '12 at 13:22
    
You could also move to a cloud service, which essentially will move your site transparently if a single node goes down - it depends what you have at the moment, and what your budget is. Are you running a shared/VPS/dedicated box? What OS? –  halfer May 27 '12 at 13:24
1  
This is relevant: serverfault.com/questions/316637/… –  Ben May 27 '12 at 13:31
    
@Ben - I was just about to post that question. :-) –  Anonymous May 28 '12 at 14:19
add comment

3 Answers 3

up vote 1 down vote accepted

http://www.pingdom.com/ or http://newrelic.com are both really good services!

share|improve this answer
add comment

Have been using IP Sentry since it first came out on single server operations up to load balanced enterprise situations. Can't say enough good about it.

share|improve this answer
add comment

I use this Perl script to monitor all the services on my production server

#!/usr/bin/perl

use SendMail;
use IO::Socket;

#Find Server IP
$hostname="HostName";
my($addr)=inet_ntoa((gethostbyname($hostname))[4]);

@downservice = ();
@services = ( 'nginx', 'apache2', 'mysql' );
foreach my $service (@services) {
my $status = `/bin/ps cax | /bin/grep $service`;
if (!$status) {
     push (@downservice, $service);
 }
}

$sm = new SendMail("EmailServer");
$sm->setDebug($sm->OFF);
$sm->From("FromMailID");
$sm->Subject("Alert");
$sm->To("ToEmailID");
$sm->setMailBody("The Following Services are Down { @downservice } in Server $addr");

# Check if the mail sent successfully or not.
if ($sm->sendMail() != 0) {
  print $sm->{'error'}."\n";
  exit -1;
}
# Mail sent successfully.
print "Done\n\n";
exit 0;

The Script is added to the cron job and runs every 5 mins is a service is down it send's email alert

share|improve this answer
    
and how do you detect whether your script is running or your mail server? –  Del Pedro May 28 '12 at 11:33
    
To Check my mail service is running i look for the postfix service –  Rakesh May 28 '12 at 11:45
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.