<div class="gmail_quote">On 9 August 2012 23:17,  <span dir="ltr"><<a href="mailto:oyvind.bjorge@telenor.com" target="_blank">oyvind.bjorge@telenor.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Is there anyone that have made a perl module or subroutine for sending to a xymon-server without having to install the xymon client?<br></blockquote><div><br></div><div>You could use xymon-rclient (on <a href="http://xymonton.org">xymonton.org</a>), where you only need an ssh connection from the server to a shell running on the client; it automagically sends the client-side script, and injects the results on the server side.</div>

<div><br></div><div>Also, this shell one-liner works on Solaris under ksh, bash and bourne shell (sh):</div><div><br></div><div>#!/bin/sh</div><div><div>( echo "$2"; sleep 1 ) | telnet $1 1984 2>&1 >/dev/null | grep -v "closed by foreign host"</div>

</div><div><br></div><div>Run it like this:</div><div>  ./xymon.sh $XYMSRV "status `uname -n`.testname green All OK"</div><div><br></div><div>Alternatively, netcat (nc) can be used like so:</div><div><br></div>
<div>
echo "$2" | nc -w1 $1 1984 || echo "Connection failure"</div><div><br></div><div>Neither of these are ideal, because there's no way to close the connection on the client side once the message has been sent, and so it simply waits 1 second (-w1 for nc) and assumes it has all been sent.</div>

<div><br></div><div>This bash code doesn't have the same limitation.  It works on Linux and should work on all UNIXes that run bash:</div><div><br></div><div>#!/bin/bash</div><div>exec 3<>/dev/tcp/$1/1984 || exit 1</div>

<div>echo "status `uname -n`.testing green `date` $2" >&3</div><div><br></div><div>Run it as above.</div><div><br></div><div>This script uses the /dev/tcp bash-ism, so it's not portable to other shells.  If you needed to send multiple messages in a single script, you should close the socket after each with "exec 3<>-".</div>

<div><br></div><div>J</div><div><br></div></div>