<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I have a couple scripts that I run through nagios, one to check the tuners, the other for guide days… &nbsp;I believe I originally got them from somewhere online, but modified for my use. &nbsp; &nbsp;I have them plugged into Nagios as commands… &nbsp;how to set that up is an exercise for the reader.. :D &nbsp;Super simple scripts with little to no error checking/handling… but it works for me.<div><br></div><div>#######Check Tuners Script</div><div><div># cat nagios_check_mythtv.sh&nbsp;</div><div>#!/bin/bash&nbsp;</div><div># This script will check the http status page for mythtv and look for Tuner Status</div><div># the following command line arguments:</div><div># -E Encoder Name i.e. "Encoder 2"</div><div># -L Locality i.e local or remote</div><div># -H Host the encoder lives on</div><div><br></div><div>#Usage function</div><div>function Usage()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>printf "Usage: %s: [-E Encoder, i.e. 1] [-L encoder location, i.e. "local" or "remote"] [-H host]\n" $0</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>exit 3</div><div>}</div><div><br></div><div>#Setup the command line options</div><div>EFLAG=</div><div>ENCODER=</div><div>LFLAG=</div><div>LOCALITY=</div><div>HFLAG=</div><div>HOST=</div><div>while getopts E:L:H: name</div><div>do</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>case $name in</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>E)<span class="Apple-tab-span" style="white-space:pre">        </span>EFLAG=1</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>ENCODER="$OPTARG";;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>L)<span class="Apple-tab-span" style="white-space:pre">        </span>LFLAG=1</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>LOCALITY="$OPTARG";;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>H)<span class="Apple-tab-span" style="white-space:pre">        </span>HFLAG=1</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>HOST="$OPTARG";;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>?)<span class="Apple-tab-span" style="white-space:pre">        </span>Usage;;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>esac</div><div>done</div><div>shift $(($OPTIND - 1))</div><div><br></div><div>#Make sure we have all the options parsed that we need</div><div>if [ -z $EFLAG ]</div><div>then</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>echo "No Encoder Specified"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Usage</div><div>fi</div><div><br></div><div>if [ -z $LFLAG ]</div><div>then</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>echo "No Locality specified"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Usage</div><div>fi</div><div><br></div><div>if [ -z $HOST ]</div><div>then</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>echo "No Host specified"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>Usage</div><div>fi</div><div><br></div><div>#Get the output and store it in a variable</div><div>out=$(/usr/bin/wget <a href="http://mythhost/mythweb/status">http://mythhost/mythweb/status</a> --user mythuser --password mythpass -O - -q|\</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/usr/bin/html2text|\</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>egrep "Encoder $ENCODER .* is $LOCALITY on $HOST" |\</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>cut -f1 -d\&lt;)&nbsp;</div><div><br></div><div>#Do the Nagios checks</div><div>rc=0</div><div>echo $out | egrep -q "is recording|is not recording|is watching Live TV"</div><div>if [ "$?" -ne 0 ]</div><div>then</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mesg="Tuner Status Invalid: "</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rc=2</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>echo "$mesg" "$out"</div><div>else</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mesg="Tuner OK: "</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rc=0</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>echo "$mesg" "$out"</div><div>fi</div><div>exit $rc</div><div><br></div><div>#####Check how many days are in the guide</div><div><div>#######Check Tuners Script</div><div><br></div><div><br></div><div><div># cat nagios_check_mythtv_guide.sh&nbsp;</div><div>#!/bin/bash&nbsp;</div></div></div><div><div>#Usage function</div><div>function Usage()</div><div>{</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>printf "Usage: %s: \n" $0</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>exit 3</div><div>}</div><div><br></div><div>#Get the output and store it in a variable</div><div>out=$(/usr/bin/wget <a href="http://mythhost/mythweb/status">http://mythhost/mythweb/status</a> --user mythuser --password mythpass -O - -q|\</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>/usr/bin/html2text|\</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>egrep "guide data .* \(.*\)" |\</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>cut -f2 -d\(|\</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>cut -f1 -d\)|\</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>sed 's/ days//g')&nbsp;</div><div><br></div><div>#Do the Nagios checks</div><div>rc=0</div><div>if [ "$out" -gt 11 ]</div><div>then</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mesg="Gude Data OK: $out days"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rc=0</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>echo "$mesg"</div><div>else</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>mesg="Guide Data is Critical: $out days"</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>rc=2</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>echo "$mesg"</div><div>fi</div><div>exit $rc</div></div><div><br></div><div><br></div><div><div>On Jun 18, 2013, at 7:48 AM, Tom Lichti &lt;<a href="mailto:tom@redpepperracing.com">tom@redpepperracing.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 18, 2013 at 8:31 AM, Simon Hobson <span dir="ltr">&lt;<a href="mailto:linux@thehobsons.co.uk" target="_blank">linux@thehobsons.co.uk</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">LAUKENS Niels wrote:<br>
&gt;Although this is getting off-topic, for the record: Nagios can accept<br>
&gt;"alerts" from pretty much anywhere. Either use "send_nsca", or write<br>
&gt;directly to the "external command file" with your updated information.<br>
<br>
</div>Indeed. Plus, for active monitoring, if you can write a script to do it, Nagios can monitor it. In essence, the monitoring side of Nagios is just calling scripts and processing the response code (OK, Warning, Critical, Unknown). So pretty well all you need to do is write a script (optionally taking some parameters), and have it spit out a one-line result - whatever goes inside is up to you and can be as simple or complex as you like/need/can cope with.<br>

<br>
Though I have to agree with an easrlier comment - it's a bit heavyweight, and has a fairly steep learning curve until you get your head round it.<br>
<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>Yeah, unfortunately (fortunately?) I have a *lot* of experience with it. I originally started using it when it was still called Netsaint (circa 2000) . Now I am a slave to HP... :)</div>
<div><br></div><div>Anyway, if I get some time I'll try and take a look at the plugin and see what it does, it could be relatively easy to port to a newer version of MythTV.</div><div><br></div><div>Tom&nbsp;</div></div></div>
</div>
_______________________________________________<br>mythtv-users mailing list<br><a href="mailto:mythtv-users@mythtv.org">mythtv-users@mythtv.org</a><br>http://www.mythtv.org/mailman/listinfo/mythtv-users<br></blockquote></div><br></div></body></html>