One of the biggest annoyances to me when doing research on the internet is when I find an enticing summary from a search engine query, but, when I try to access the resource, the website is not accessible because [the database server was down | enter your reason here]. This is why for the year of 2009, I am going to be more proactive in monitoring my server’s reliability.
I chose Pingdom, a company that specializes in uptime monitoring services. The 70% off holiday special didn’t hurt that decision either. For a measly $35 this year, I will be notified the minute (literally) that there is a problem with my server. [Track my server (Swift) uptime]
One of the relatively new features that Pingdom added to their services is the ability to call your own scripts on the server and set your own status report. This allows more comprehensive tests that go beyond a simple ping. I use this functionality to check the status of services that I don’t want accessible on the internet directly (e.g. MySQL) as well as server vitals like RAM usage. Here are two simple PHP scripts that demonstrate how I am using the services from Pingdom with their HTTP Custom check.
This is my core services check. It makes sure that web services and MySQL are operational. Simply configure the script with the username and password of a MySQL database. If the script cannot make a connection to the database server, then a ‘MYSQL DOWN’ status will be returned to Pingdom. Of course, if the script doesn’t respond at all, then the web service is down and Pingdom will report a down status.
This script is intended to be an early warning system. It will raise the alarm if something looks out of the ordinary so that I can be prepared for a possible service failure. The following server vitals are checked: swap usage, hard drive usage, and cpu usage. If any one of these goes beyond the preset thresholds, a down status will be returned to Pingdom.
You might be thinking that checks like these could be done with a monitoring script on the server without using Pingdom at all, and there is merit to that argument. However, if you run out of memory and your system comes crashing to a halt, that probably means that services like email, which you would have used to alert yourself to the problem, would no longer be working. By performing these checks remotely, you can sleep a little easier. Plus, Pingdom will generate nifty looking graphs, and I like graphs.
–Added on 12/4/2009–
This script is a combination of pingdom-core.php and pingdom-server.php if you’re using the free acount
Ideas for the future
I would like to check the Apache or Nginx status reports to determine how many connections there are. This may be useful in detecting a digg or slashdot to temporarily boost resources before it becomes a problem.
How do you track your server’s reliability? Leave a comment below.