Nagios check plugin for MythTV

Nagios is an Open Source host, service and network monitoring application that I use to monitor a couple of servers I have at home as well as a couple out on the Internet that I look after. One of my home servers is a Home Theatre PC running Linux and MythTV, and while Nagios checks to make sure its up and monitors its disk space, load & temperature, I wanted to check MythTV itself so I wrote a check plugin to do just that.

The check_mythtv plugin connects to the mythbackend process to make sure its running. It reports the status of the tuners and checks to see how much program guide is available:

$ ./check_mythtv.pl -H mythpvr
Ok: Tuners idle, 7 days program guide available

Normally I have around 7 days worth of guide data so I set the plugin to generate a warning alert (via email) if it falls to 4 days and a critical alert at 2 days. The plugin is a simple Perl script so it could easily be modified to check other things.


DownloadDescriptionVersionUploaded
check_mythtv.plNagios plugin for MythTV1.112-02-2011

3 Comments

  • jima says:

    Have you tested this in a single-tuner environment?  Maybe it's just the screwed-up MythDora install, but as-is, it bombed out terribly.  (Although now that I look a little closer, the implications I'm seeing are that it's the XML-parsing.)  Instead of storing the configuration options in $ref->{Encoders}->{Encoder}->{$encoder}, it's stored directly in $ref->{Encoders}->{Encoder} — so to get the state, one would have to look at $ref->{Encoders}->{Encoder}->{state}.  It's a little wacky.  $ref->{Encoders}->{count} does give the number of encoders, fortunately, so it's easy enough to check and alter the method accordingly.  I've hacked together a few different set of changes, the sanest of which I've posted here:  http://beer.tclug.org/jima/text/check_mythtv.pl.txtIf you'd like to write a cleaner solution, feel free to email me for the XML dumps (I have a single-tuner and a 4-tuner environment that I used to test this code).

  • Steve says:

    Thanks for the feedback Jima. I have two tuners so haven't tested it with a single tuner. I've looked through your changes and tested them on my system and they seem fine so I've updated the plugin.

  • jima says:

    Thank you for the plugin!  I discovered it the day after you posted it, coincidentally enough.  (Luckily, Google seemed to pick up your post right away.)  I'd written a plugin to monitor the serial connections to my DirecTV D11s (they keep losing synch for some reason), and it occurred to me that maybe I could monitor MythTV as well.  It worked without a hitch on my setup, but not so well on an associate's, ergo the changes.

Leave a Reply