[Xymon] ext script does not show up at webpage
Simon HĂžjberg Jespersen
Simon.Jespersen at stab.rm.dk
Tue May 13 13:25:53 CEST 2014
Hi xymon list
This is my first post, and it is about a custom script on a sun solaris client.
I have a script placed at
/home/bb/client/ext/monitorfs_xymon.sh on the client
It is doing some disk check and end up with this command
$xymon $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"
When I echo this command line to a file for debug
The full commandline looks lige this
/home/bb/bin/xymon "10.83.82.9 status aarapp144.available storage green Tuesday, 13 May 2014 13:10:20 CEST Looking good"
When I try to run it from commandline the output is
Xymon version 4.3.17
Usage: /home/bb/bin/xymon [--debug] [--merge] [--proxy=http://ip.of.the.proxy:port/] RECIPIENT DATA
RECIPIENT: IP-address, hostname or URL
DATA: Message to send, or "-" to read from stdin
Can anybody help me to figure what is wrong , I think i followed to description in tips & tricks.
Another question, can I use the cfg script to source my own variable to use in scripts ?
Regards Simon
PS..
/* the whole script */
#!/usr/bin/bash
FILESYSTEMS=/,/export,/local
IFS=","
MACHINE=`hostname`
COLUMN="available storage"
COLOR=green
MSG="Looking good"
TRESHOLDUSEDGB=50
TRESHOLDMAXPROCENTUSED=100
TRESHOLDAVAILGB=10
function teratogb {
tb=$1
echo $((GB*1024))
}
function kbtogb {
kb=$1
#echo $1
echo $((kb/1024*1024))
}
function measurement {
in=$1
len=${#in}
tp=${in:len -1:1}
if [ "$tp" == "K" ]
then
in=${in:0:len -1}
kbtogb $in
fi
if [ "$tp" == "T" ]
then
echo "$1 :call teratogb with"
echo ${in:0:len -1}
fi
if [ "$tp" == "G" ] || [ "$tp" == "%" ]
then
value=${in:0:len -1}
x=0
returnvalue=""
while [ $x -lt $len ]
do
ch=${value:$x:1}
if [ "$ch" == "." ]
then
break
else
returnvalue=$returnvalue$ch
fi
x=$((x + 1))
done
echo $returnvalue
fi
}
for i in ${FILESYSTEMS};do
lfil=`df -h $i | tail -1` >> /dev/null
usedgb=`echo $lfil | awk ' { print $3 } '` >> /dev/null
usedgb=`measurement $usedgb` >> /dev/null
if [ $usedgb -ge $TRESHOLDUSEDGB ]
then
COLOR="red"
MSG="Treshold used space on $i exceeded the limit set on $TRESHOLDUSEDGB gb "
fi
availgb=`echo $lfil | awk ' { print $4 } '` >> /dev/null
availgb=`measurement $availgb`
if [ $availgb -le $TRESHOLDAVAILGB ]
then
COLOR=red
MSG="Treshold available diskspace on $i exceeded the limit set on at least $TRESHOLDAVAILGB gb "
fi
procentused=`echo $lfil | awk ' { print $5 } '` >> /dev/null
procent=`measurement $procentused` >> /dev/null
if [ $procent -ge $TRESHOLDMAXPROCENTUSED ]
then
COLOR=red
MSG="treSHOLD ON MAXIMUM USED DISKSPACE IN PROCENT ON $I EXCEEDED THE LIMIT SET TO $trESHOLDMAXPROCENTUSED"
fi
done
echo "$XYMON $XYMSRV status $MACHINE.$COLUMN $COLOR `date` ${MSG}" >> /tmp/du_i_run.log
$XYMON $XYMSRV "status $MACHINE.$COLUMN $COLOR `date` ${MSG}"
exit 0
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20140513/7553abe6/attachment.html>
More information about the Xymon
mailing list