[Xymon] Contents of root's crontab in ps list?

Jeremy Laidman jlaidman at rebel-it.com.au
Thu Feb 5 10:44:14 CET 2015


On 05/02/2015 2:30 PM, "John Palys" <johnpalys at schoolpathways.com> wrote:

> A simple script. Same script is running on all servers, only some have
the issue reported.

Probably because its only sometimes that the xymon client script runs at
the same time as the cron job. You'll probably find that they drift out of
sync over time, and different servers will be showing this phenomenon at
different times, because the xymon client script runs slightly later each
time (ie not exactly every 5 minutes).

> LOGFILE=/tmp/cron_list.log
>
> cat /var/spool/cron/root > /tmp/cron_list.log

snip (why not use $LOGFILE here)

> cat /var/spool/cron/cworks >> /tmp/cron_list.log

> RESULT=`cat $LOGFILE`
>
>
> LINE="status $MACHINE.$TEST $COLOR `date`
>
> $RESULT"
>
> $XYMON $XYMSRV "$LINE"

This is the problem. The contents of cron_list.log (ie a copy of the
crontab) is put into $RESULT and in turn into $LINE. Then the text is given
to the xymon command as a parameter, for all to see in ps output.

As soon as you use backticks, you're going to get into trouble. You can't
do anything useful with $RESULT without its contents appearing on a command
line in ps output, should it happen to run at the same time.

Instead, use the alternative form of running xymon, by specifying a
parameter of "@" and feeding the message on stdin.  Like so:

LINE="status $MACHINE.$TEST $COLOR `date`
{ echo "$LINE"; echo; cat $LOGFILE; } | $XYMON $XYMSRV "@"

And get rid of the line that sets $RESULT cos you don't need it anymore.

J
 Jeremy,

A simple script. Same script is running on all servers, only some have the
issue reported.  The xymon ../ext/crontab.sh which sends the output TO the
xymon server is identical to the mis-behaving servers.

--------------------
#!/bin/bash

LOGFILE=/tmp/cron_list.log

cat /var/spool/cron/root > /tmp/cron_list.log

if [ -f /var/spool/cron/cworks ]; then
echo "================================" >> /tmp/cron_list.log

cat /var/spool/cron/cworks >> /tmp/cron_list.log

else echo ""
fi
-----------------------
#!/bin/sh

#

# Standard XYMON stuff

#

if [ "$XYMONHOME" = "" ]; then

   echo "XYMONHOME is not set... exiting"

   exit 1

fi



if [ ! "$XYMONTMP" ]; then

   . $XYMONHOME/etc/bbdef.sh

fi





#-----------------------

# EDIT Variables here

#-----------------------

TEST=crontab
COLOR=green
LOGFILE=/tmp/cron_list.log
TMPFILE=$XYMONHOME/tmp/$TEST.tmp

RESULT=`cat $LOGFILE`


LINE="status $MACHINE.$TEST $COLOR `date`

$RESULT"

$XYMON $XYMSRV "$LINE"

#rm -f $BBTMP/$TEST.tmp

#rm -f $TMPFILE
-------------------------------------

On Wed, Feb 4, 2015 at 6:54 PM, Jeremy Laidman <jlaidman at rebel-it.com.au>
wrote:

> Ben
>
> On 5 February 2015 at 13:03, Benjamin Smith <lists at benjamindsmith.com>
> wrote:
>
>
>> # cat crontab files to /tmp/cron_list.log for xymon crontab.sh
>> 0 * * * * /root/bin/std/show_crontab.sh??#XYMON?#?
>>
>
> What does this script (show_crontab.sh) do?
>
> Cheers
> Jeremy
>



-- 
John Palys
School Pathways, Inc.
866-200-6936 #2010 * Office*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.xymon.com/pipermail/xymon/attachments/20150205/a22d604c/attachment.html>


More information about the Xymon mailing list