Munin monitoring… for Windows, for Embedded devices, for great justice!

I use Munin to monitor stuff on the home network. Recently, I added a couple monitors – one is a simple web scrape for the new Boxee box that replaced the dedicated HTPC running GBPVR, the other for a Win7 VM (running under Virtual Box on my Ubuntu server, just like the CentOS image that drives this Drupal blog…) needed to run the Boxee Media Manager and also to stream content to the Xbox.

Let's talk about the easy one first: All you need to do to monitor a Windows 7 machine is install the wonderful Munin-Node-Win32 as a service. Tweak the included .ini file (which you will find in the install directory) and then stop/start the service, and you're done. Add the machine to your overview munin.cfg file on your monitor machine, restart munin-node there, and wait 5-10 minutes for data to start flowing. After a bit you'll have awesome graphs like this one:

The Boxee Box is another story. Like a lot of little appliance-like things, it has a web interface. Unfortunately it doesn't really give you much to work with! You get to the web interface by hitting the machine at port 8080. You'll get not much of use except the fan speed and CPU Temp, in a table, along with access to recent log dumps. We'll take what we get and scrape off the two data points for our graph by making a new plugin running on the host box. All we need to do is pull the data out from the webpage with curl, hack it up with the ugliest hack of sed you'll ever see, and hey presto we're done. Here's the script:

$ more /etc/munin/plugins/boxeebox
#!/bin/sh

case $1 in
   config)
        cat <<'EOM'
graph_title Boxee Box stats
graph_category boxee
graph_info This graph shows boxee box stats
cpu.label temp
cpu.info CPU Temperature C
fan.label fan
fan.info fan speed %
EOM
        exit 0;;
esac

curl --connect-timeout 5 -s  "http://boxeebox.schettino.us:8080"| grep \<td\> | 
  sed -n -e '4s/^<tr><td>CPU Temperature:<\/td><td>/cpu.value /' -e '4s/ C<\/td><\/tr>//' 
  -e '5s/^<tr><td>Fan Speed:<\/td><td>/fan.value /'  -e '5s/%<\/td><\/tr>//'  -e '4,5p'

Yeah, it's ugly. All its doing in that curl call is stripping out the two values, and spitting them out as a pair of tag value sets that munin can digest. Munin will take that and make you a pretty graph:

I used the same technique to graph the stats from the Comcast business class router here.