[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:34 +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=E0cNsuUDFBOxsniR95/Deny89bQ0dQIxi744dM3TXlw=; b=ZLq5Za8IrfkaM/ZjjYuNX4mE29euGGR6nvr7E4iros2s8dKcjOitBA7OZKKibM53rL 4LP6j+IdAQtsKKb3MxMpthq0SlMF6HBQMrznvzF3nZ2BSYXaELCldEgE6ow/vTFAqq58 hB2/rPltOq4M6EPu1jN3WpBmtC/a1B3ecw/kI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=Fs845+19gwWGklqY0M8o0g+YmV0mrIWJK4446/Wd/LUzw1rpVMgvxTbhvHx1HNZspM Tvl0jSkG54N42/sZwvfmRRonWZCRgdPZCeA/9HnhoHfd2zfGRjIJ3ILa9IH//iFa4R3I I57NXTzKoIsfyPBAYXP22RLp+ek2DzEFbwpDo=
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