[Xymon] xymon-rclient
Adam Goryachev
mailinglists at websitemanagers.com.au
Thu Aug 7 01:34:19 CEST 2014
On 07/08/14 00:39, Jeremy Laidman wrote:
> I'd put this in a script like so:
>
> #!/bin/sh
>
> TESTNAME="foo"
> REGEX="some regex"
>
> do_fetch() {
> wget ... --header="SOAPAction:
> \"http://$1/ComprehensivePersonSearch\" -O - http://$2/BobService.asmx
> }
>
> $BBHOME/bin/bbhostgrep foo | while read IP HOSTNAME OTHER; do
> if do_fetch $HOSTNAME $IP | grep "$REGEX" > /dev/null ; then
> COL=green
> MSG="Test for $TESTNAME is OK"
> else
> COL=red
> MSG="Test for $TESTNAME failed"
> fi
> $BB $BBDISP "status $HOSTNAME.$TESTNAME $COL `date` $MSG"
> done
>
> This is from memory and hasn't been tested, but should give you the gist.
>
Just a thought, couldn't this have used the cont check?
In any case, to explain the script to the OP, this line:
$BB $BBDISP "status $HOSTNAME.$TESTNAME $COL `date` $MSG"
The HOSTNAME value is taken from the xymon hosts file, and used to tell
xymon where to place the colored dot with this result.
Also, perhaps the following changes would be helpful:
if do_fetch $HOSTNAME $IP | grep "$REGEX" > /dev/null ; then
result=`do_fetch $HOSTNAME $IP`
if `echo "$result" | grep -q "$REGEX"`; then
COL=green
MSG="Test for $TESTNAME is OK
$result"
else
COL=red
MSG="Test for $TESTNAME failed
$result"
fi
This may be useful to know what the actual value was when you got an
error, or even what the actual value was when it changed from non-green
to green. Of course, if $result is a large amount of data, then you may
not want to display the full value, you can pass it through grep or
other tools to reduce it down to a smaller/more useful amount of data.
Note, the above hasn't been tested at all, so watch for syntax or other
errors, but hopefully it will be useful.
Regards,
Adam
--
Adam Goryachev Website Managers www.websitemanagers.com.au
More information about the Xymon
mailing list