alert script problem using curl

Phil Meech pmeech at gmail.com
Mon Mar 15 09:33:35 CET 2010


Hi All,

I've been having a problem getting some ext scripts working correctly that
use curl on Xymon 4.2.3.  All the scripts work fine if the IP is hardcoded
into the script itself and run outside of Xymon.  However, if the scripts
are called from Xymon, although the IP is passed and handled correctly the
script will fail.  An example of such a script is as follows:

#!/bin/bash
# timestamp
#MACHIP=192168001001
echo `date` >> /tmp/cpu_reboot.log
MACHIP=`echo $MACHIP|sed -e :a -e 's/\(.*[0-9]\)\([0-9]\{3\}\)/\1.\2/;ta'`
MACHIP=`echo $MACHIP | sed 's/\b\(0*\)//g'`

echo $MACHIP >> /tmp/cpu_reboot.log
if  [ ${RECOVERED:-0} -eq 0 ]; then
        # Login to a box
        echo "Logging in to $MACHIP" >> /tmp/cpu_reboot.log
        curl -v -L --insecure -A "Mozilla/4.0 (compatible; MSIE 5.01;
Windows NT 5.0)" -b cookies.txt -c cookies.txt -d
"username=myusername&pw=mypassword" https://$MACHIP/goform/Logout -e
https://$MACHIP/home.asp
        echo "RESULT: $?" >> /tmp/cpu_reboot.log
        # Issue a reboot via post to form
        sleep 10
        echo "Issuing reboot instruction to $MACHIP" >> /tmp/cpu_reboot.log
        curl -v -L --insecure -o /tmp/cpu_reboot-step2.log -A "Mozilla/
4.0 (compatible; MSIE 5.01; Windows NT 5.0)" -b cookies.txt -c cookies.txt
-d "r
eset=Restart" https://$MACHIP/goform/FormResetFactory -e https://$MACHIP/
home.as
p
        echo "RESULT: $?" >> /tmp/cpu_reboot.log
        echo "--------------------------------------------" >>
/tmp/cpu_reboot.log
fi

The above script is an alert script which is fired when a devices CPU load
stays at 100% for over 4 hours.  In this instance, I am issuing a reboot on
the alert.  The echo commands are largely in there for debug purposes, and I
know the script can be tidied up a lot; however it is function from the
shell (which is bash incidentally).
The log of this script when called from Xymon indicates that after the
initial login (which works fine), the second curl command generates an error
from the device saying that an administrator is already logged in.  Oddly, I
cannot simulate this error manually, and I've tried locking the devices
until the previous administrator has logged out; after the first curl
command login I still get the same error.

Has anyone else experienced a similar issue, or would know where I should be
looking to resolve this issue?

ps: the OS is Ubuntu Server 9.10.  If it's any help the output can be
posted, though it'll take me some time to clean it for posting!

Many Thanks,
Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20100315/16a89953/attachment.html>


More information about the Xymon mailing list