Nagios, Belkin WeMo and a Plasma Globe

by Thomas Beutel

Plasma GlobeI monitor a number of servers using nagios and I always thought it would be neat to be able to have some sort of ambient device light up when there was a critical problem.

Yes, I get email and text alerts, and nagios is always up in one tab on my browser, but I wanted to have something there in the periphery of my vision just as an extra queue. Well a couple of years ago I got a small plasma globe and it’s really cool, but I wasn’t using it much just by itself. So it occurred to me that it would be the perfect device to have light up when nagios detected a problem. I’ve been wanting to do this for the longest time but it wasn’t until Belkin came out with WeMo that I figured out how to do it and it was pretty easy.

I plugged the plasma globe into a WeMo Switch and configured the switch with the free WeMo iPhone app. Then I created the following Perl script that I call

use warnings;
use strict;

# Get the following packages from CPAN
use WebService::Belkin::WeMo::Discover;
use WebService::Belkin::WeMo::Device;

# Create connection to my WeMo switch
my $wemo = WebService::Belkin::WeMo::Device->new(ip => '', db => '/etc/belkin.db');

# Grab HTML of Nagios status page
my $html = `curl --user nagiosadmin:<password> --silent 'http://<my-server>/nagios/cgi-bin/status.cgi?host=all'`;

# Look for serviceTotalsCRITICAL or hostTotalsCRITICAL
if ($html =~ m/(serviceTotalsCRITICAL|hostTotalsCRITICAL)/i ) {
} else {

Then I added the script to my crontable:

* * * * * /Users/thomas/code/

Now, any time a server or service goes critical, the plasma globe turns on, and when the problem is resolved, it turns off.

I used Perl for the script, but you could also just use a shell script such as this one here.