I recently stumbled upon the site Server Density while upgrading all my servers and signed up for the service. It as a great pretty interface, a customizable dashboard, and pretty extensive alert capabilities. They also have a free trial so I suggest signing up. The one thing I did not like was the inability to scan for a specific string on the website to confirm if the website is still operational, like with host-tracker.com.
The good news is Server Density allows you to create python plugins to run at the update interval on any/all of your servers. This gives you free reign over your reports. Using this tutorial, I will explain how to manually create and install this and any other plugin. Or you can just download or install it from the below links.
GitHub - https://github.com/arzynik/sd-webcheck
Server Density Plugin - http://plugins.serverdensity.com/webcheck
Create your plugin
First, log into your SD account and go to Plugins. Then add a new plugin and name it WebCheck.
Add your plugin to your server
Next you will need to ssh into your server and create the directory
mkdir /usr/bin/sd-agent/plugins/
In that directory, create a new file called WebCheck.py. This will be the main and only file for the plugin. Grab the code from https://github.com/arzynik/sd-webcheck/blob/master/WebCheck.py and paste it into the file.
Configure your plugin
If this is your first plugin, you will need to add your plugin directory to your plugin config file. Open up /etc/sd-agent/config.cfg and replace the plugin_directory line with
plugin_directory: /usr/bin/sd-agent/plugins
WebCheck allows you to check the status of as many sites as you want. In order to check they you will need to enter a new config entry for each site, using the below fields:
- name - The name and key you want to use on the SD interface. Remember that all "." will be replaced with "_" due to api limitations.
- url -
- find - The regex or string to search for. I typically just use an html tag but you can search for anything.
- result - The result is the regex quantifier. Lets say you want to search from </html>, you would keep this True. Or lets say you want to search for Parse Error, you would then make this False.
Here is an example config entry
[WebCheck 1]
name: devin.la
url: http://devin.la/
find: </html>
result: True
Restart the agent service to load the changes. Once it is restart it will begin sending data to SD
/etc/init.d/sd-agent restart
Settings up alerts
Because WebCheck only returns a boolean result, you probably wont be using it with graphs much. The alerts, however, are extremely useful. I personally recommend the iPhone push notifications, as they are uber fast.
- In your Server Density account, go to Alerts and click add new alert.
- Select your server that you installed it on, who is going to get it, and the alert type.
- For Check, select WebCheck.
- For Key, enter the name of your config entry. For me it is devin_la.
- For Trigger threshold, set it to Less than 1.
- Add it and you now know when your server is messed!
I love it!
One of my developers was working on a site and pushed some naughty changes to one of the sites I had just set up with this, and within seconds i got a push notification that it was broken. He fixed it pretty quick and it then alerted me when it was all fixed! Please share your cool plugins with me!