<div dir="ltr">Thanks for the ideas Jeremy (as always :-) ), will check with the first option.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Sep 22, 2014 at 11:47 PM, Jeremy Laidman <span dir="ltr"><<a href="mailto:jlaidman@rebel-it.com.au" target="_blank">jlaidman@rebel-it.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class=""><div class="gmail_quote">On 23 September 2014 13:34, deepak deore <span dir="ltr"><<a href="mailto:deepakdeore2004@gmail.com" target="_blank">deepakdeore2004@gmail.com</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT:#ccc 1px solid;MARGIN:0px 0px 0px 0.8ex;PADDING-LEFT:1ex" class="gmail_quote">Do we need to source xymonclient.cfg into normal shell scripts so that $BB $BBDISP $MACHINE etc. variables will work?</blockquote></div>
</span><div><br>Not absolutely required, but depending on how clever you want to be, they can be helpful.</div>
<div> </div>
<div>To give you an idea, this might do what you want, without setting any variables:</div>
<div> </div>
<div>#!/bin/sh</div>
<div> </div>
<div>cp /path/to/access-file /path/to/access-file.backup</div>
<div>printf "allow him\ndeny her\nallow from all\n" > /path/to/access-file</div>
<div>if apachectl -t >/dev/null; then</div>
<div>    # is OK</div>
<div>    apachectl graceful</div>
<div>    /usr/lib/xymon/client/bin/xymon 10.1.2.3 "status `uname -n`.apachecheck green `date` everything's fine with apache"</div>
<div>else</div>
<div>    # is failed</div>
<div>    cp /path/to/access-file /path/to/access-file.bad</div>
<div>    cp /path/to/access-file.backup /path/to/access-file</div>
<div>
<div>    /usr/lib/xymon/client/bin/xymon 10.1.2.3 "status `uname -n`.apachecheck red `date` something's not right with apache"</div></div>
<div>fi</div>
<div> </div>
<div>Now the problem arises when you add a second Xymon server, or if you change IP addresses of the Xymon server.  The 10.1.2.3 is no longer suitable.  So that's when you want to define $XYMSERVERS="10.1.2.3 10.4.5.6" and then specify 0.0.0.0 as the server instead of 10.1.2.3, and then the xymon client will post messages to both servers as listed in the $XYMSERVERS environment variable.</div>
<div> </div>
<div>Then let's say you want to run the script on another Apache server, but it has its Xymon client installed in a different location.  So you need to have two versions of the script, one using /usr/lib/xymon/client/bin/xymon and another using /usr/local/xymon/client/bin/hobbit.</div>
<div> </div>
<div>etc</div>
<div> </div>
<div>The easiest way to do this is to make use of the variables, and then either the script within a xymoncmd wrapper (which sets all of the variables you need) or from tasks.cfg (which can also set the variables you need).  You end up with something like this:</div>
<div> </div>
<div>
<div>    $XYMON $XYMSRV "status $MACHINE.apachecheck red `date` something's not right with apache"</div>
<div> </div>
<div>This works on any of your Xymon clients, no matter how they're setup.</div>
<div> </div>
<div>Here's another idea.  You can have your script create a log entry using "logger" and then have Xymon's log watching code detect the anomaly and warn accordingly.</div><span class="HOEnZb"><font color="#888888">
<div> </div>
<div>J</div>
<div> </div></font></span></div>
</blockquote></div><br></div>