[Xymon] custom script fails when I add ssh command

oliver ohemming at gmail.com
Thu Dec 15 22:01:07 CET 2011


I have 6 servers in my hosts.cfg file that use a custom script with a
HOSTTAG of cdr

The script is located at $XYMONHOME/ext/check_cdr.sh

If I make it as basic as possible, it all runs perfectly.  For example:

================================
#!/bin/bash -x

HOSTTAG=cdr
COLUMN=$HOSTTAG

$XYMONHOME/bin/xymongrep $HOSTTAG | while read L
do
   set $L       # To get one line of output from xymongrep
   HOSTIP="$1"
   MACHINEDOTS="$2"
   MACHINE=`echo $2 | $SED -e's/\./,/g'`
   COLOR=green
   MSG="running on ${MACHINE}"
   $XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date`
   ${MSG}
   "
done

exit 0
================================

I realise the test itself is useless, it's just to demonstrate the problem.

Since I have the -x on the first line, I see it iterate through all 6
servers in the log file I specified in the tasks.cfg file

This is part of the output, going from the first server to the second

+ /apps/xymon/server/bin/xymongrep cdr
+ read L
+ set 10.64.91.99 as1wdc1 '#' cdr
+ HOSTIP=10.64.91.99
+ MACHINEDOTS=as1wdc1
++ echo as1wdc1
++ /usr/bin/sed '-es/\./,/g'
+ MACHINE=as1wdc1
+ COLOR=green
+ MSG='running on as1wdc1'
++ date
+ /apps/xymon/server/bin/xymon 127.0.0.1 'status as1wdc1.cdr green Thu
Dec 15 20:57:41 GMT 2011
   running on as1wdc1
   '
+ read L
+ set 10.64.123.67 as2dal1 '#' cdr
+ HOSTIP=10.64.123.67
+ MACHINEDOTS=as2dal1


But if I add the following line to the script,  directly above the
"$XYMON $XYSERVER... " one, I only see the first server get queried
before the script exits and ultimately, my other 5 servers go purple.

/usr/bin/ssh bwadmin@${MACHINE} "hostname"

With the ssh line, my last bit of output in the log file is:

+ /usr/bin/ssh bwadmin at as1wdc1 hostname
AS1WDC1
++ date
+ /apps/xymon/server/bin/xymon 127.0.0.1 'status as1wdc1.cdr green Thu Dec 15 20
:52:37 GMT 2011
   running on as1wdc1
   '
+ read L
+ exit 0

What is it about the ssh command that causes the "while read L" loop to fail?

Thanks



More information about the Xymon mailing list