Bas Grolleman’s Blog

Place where I put my written thoughts, though I usually just make video’s these days

Uptime Robot is an excellent tool if you want to know if the site is up, but it won’t tell you much about system health. It’s either down or up and let’s face it, we much rather avoid the down. The professional solution would be to configure Nagios, Zabbix or any of the other tools to monitor the box, but it is a bit of overkill to setup a seperate box just to monitor your one or two VPS boxes.

So here is a super simple way to monitor system health, and should only take you 10 minutes to setup. I’m assuming Debian/Ubuntu here and some basic Linux skills, if you don’t know how to use chmod/ls/ln and other commands, than really, what are you doing here?

First thing we are going to do is install the nagios plugins, just the plugins. If you get hundreds of dependencies you are doing it wrong.

apt-get install nagios-plugins-basic

So, once this is done you have a nice toolkit of script to do quick monitoring. Now create a small shellscript to run all the things you would like to check, I’m running a nginx system with MySQL, so here is my script.

#!/bin/sh
NAGIOS=/usr/lib/nagios/plugins
# Simple Disk Space Check
$NAGIOS/check_disk -w 75 -c 90

# Load Check
$NAGIOS/check_load -w 3,2,1 -c 6,4,2

# MySQL Running?
$NAGIOS/check_procs -w 1:1 -c 1:1 -C mysqld

# NGINX Running?
$NAGIOS/check_procs -w 2:10 -c 2:10 -C nginx

# PHP CGI Running?
$NAGIOS/check_procs -w 16:16 -c 10:22 -C php-cgi

Run the script and check if everything results into OK, if not, either adjust monitor of fix the issue.

Now we add the following to the cron

* * * * * root SCRIPT > WEBROOT/uptime_robot.txt

For added security, replace “uptime_robot” with a nice long random string, or even better a basic authentication password, whatever works for you.

For those paying attention, we now have a public available text file with the result of our checks in it. Now all we need to do is add it to Uptime Robot.

Pick keyword checking, and configure the URL where you generate your check file. Now all we need to do is create 2 checks, one for WARNING and one for CRITICAL. Update settings to suit your needs, like critical 24×7 and warning only during daytime.

That’s it, told you it would be easy.