[Xymon] Preventing Purple - Periodical Checks

Roland Soderstrom Rolands at logicaltech.com.au
Tue Sep 23 00:11:29 CEST 2014


I got a slightly different approach that seems to work fairly well for several same type tests.
I got several things I run the same way, periodically so xymon would go purple.
Usually it is cronjobs that runs doing whatever, but we added some xymon functionality to them.
They output xymon data to a couple of files that xymon then checks through a standard xymon  script.
DATAFILE that shows whatever data from the cronjob.
COLOR that just shows the color.
HEADER just a one liner test heading in HTML.
I then have xymon checking the age of the color file and just report on that color.
For one test that is a binary we just run a wrapper cronscript that makes the xymon data and runs the binary.
The application team has all control over what is put in the xymon files without the need to become root or the xymon user.

TEST=MYrpt
MYRPTDIR=/var/tmp
MYRPTBASE=MY-reports-xym
MYRPTDATAFILE=${MYRPTDIR}/${MYRPTBASE}.data
MYRPTCOLOR=${MYRPTDIR}/${MYRPTBASE}.color
MYRPTHEADER=${MYRPTDIR}/${MYRPTBASE}.header
ERRORTEXT="<H3>ERROR: the ${MYRPTCOLOR} file is older than one day.</H3><BR>
That probably means that the cronjob for checking the MY reports hasn't run.<BR>
Please check this in `hostname`<BR>
`ls -l ${MYRPTCOLOR}`"

# Check that the color file is less than 1 day old, if not the cronjob haven't run.
AGE=`find ${MYRPTDIR} -name ${MYRPTBASE}.color -a -mtime +1`
if [ -n "$AGE" ]
then
   HEADER=`cat ${MYRPTHEADER}`
   COLOR=red
   DATA="$ERRORTEXT"
else
   HEADER=`cat ${MYRPTHEADER}`
   COLOR=`cat ${MYRPTCOLOR}`
   DATA=`cat ${MYRPTDATAFILE}`
fi
LINE="status $MACHINE.$TEST $COLOR `date`
${HEADER}
${DATA}
"

# Send to Xymon Server
$XYMON $XYMSRV "$LINE"



-      Roland
From: Xymon [mailto:xymon-bounces at xymon.com] On Behalf Of Tres Finocchiaro
Sent: Tuesday, 23 September 2014 6:28 AM
To: Michael Short
Cc: xymon at xymon.com
Subject: Re: [Xymon] Preventing Purple - Periodical Checks

@Paul/Mike,

Top notch.  I decided to put the entire delay value in the string to prevent a syntax error if it's blank.  In our case, we check a few times from noon until 6PM, so I chose 20 hours.

# Delay for Xymon to prevent purple
DELAY="+20h";
# Friday, add two more days
if [[ $(date +%u) == 5 ]] ; then
   DELAY="+68h";
fi
# [...]
xymon 127.0.0.1 "status${DELAY} $server.$service $color $msg"

P.S. I don't know how we ever survived on a Windows platform.  This product was meant for Linux and it's tremendously useful scripting capabilities. :)

Thanks again.

-Tres

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20140922/c4ad4c80/attachment.html>


More information about the Xymon mailing list