[Xymon] custom script fails when I add ssh command

Ralph Mitchell ralphmitchell at gmail.com
Fri Dec 16 02:04:00 CET 2011


I think ssh is "draining" the input stream, which in this case means the
pipeline coming into the while loop.  Try redirecting the ssh input stream
from /dev/null:

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

I tested that with this command line:

     ls | while read a; do ssh 192.168.1.4 hostname < /dev/null ; done

and got back the remote host name once for each file in the local directory.

Ralph Mitchell


On Thu, Dec 15, 2011 at 4:01 PM, oliver <ohemming at gmail.com> wrote:

> 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
> _______________________________________________
> Xymon mailing list
> Xymon at xymon.com
> http://lists.xymon.com/mailman/listinfo/xymon
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20111215/c67dc62d/attachment.html>


More information about the Xymon mailing list