[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
alert script problem using curl
- To: hobbit (at) hswn.dk
- Subject: alert script problem using curl
- From: Phil Meech <pmeech (at) gmail.com>
- Date: Mon, 15 Mar 2010 08:33:35 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=U2NsVxAAT7d1vNif1F1MFFDGyyM8Jl1xqVEhULsTf9k=; b=U//gsAelVahR5MOrrncbLfA/F0HmhpXE0FGoYrDDYgyzML78gljqRkYWGrKuUirinn K6y71qK04bkKz61SZLg3vcuHaziMt9la3ErR1AME5q4fttkQ7RNAUVo0HO3CLSV9G2HO cC+ZOMIw59x/W5EmV1vJqM6RFcjOrawOsGvJk=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=WcESwMFwv06VCblTplcJieLMFlF8XzWEyWcj9LRRM1wROAX8lA1996ApoiQlaDyE4I 6revf/adOkOfheolF5Ln/IYiGqhdoxHYCkhSaXxoFk0OK6+y7VCK4+MXosWQa+voTjfG 6gOd7Uweuel6iGygaVtFc5ThqW7bQSHAXoA2M=
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