<p dir="ltr">On 05/02/2015 2:30 PM, "John Palys" <<a href="mailto:johnpalys@schoolpathways.com">johnpalys@schoolpathways.com</a>> wrote:</p>
<p dir="ltr">> A simple script. Same script is running on all servers, only some have the issue reported. </p>
<p dir="ltr">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).</p>
<p dir="ltr">> LOGFILE=/tmp/cron_list.log<br>
><br>
> cat /var/spool/cron/root > /tmp/cron_list.log</p>
<p dir="ltr">snip (why not use $LOGFILE here)</p>
<p dir="ltr">> cat /var/spool/cron/cworks >> /tmp/cron_list.log</p>
<p dir="ltr">> RESULT=`cat $LOGFILE`<br>
><br>
><br>
> LINE="status $MACHINE.$TEST $COLOR `date`<br>
><br>
> $RESULT"<br>
><br>
> $XYMON $XYMSRV "$LINE"</p>
<p dir="ltr">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.</p>
<p dir="ltr">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.</p>
<p dir="ltr">Instead, use the alternative form of running xymon, by specifying a parameter of "@" and feeding the message on stdin.  Like so:</p>
<p dir="ltr">LINE="status $MACHINE.$TEST $COLOR `date`<br>
{ echo "$LINE"; echo; cat $LOGFILE; } | $XYMON $XYMSRV "@"</p>
<p dir="ltr">And get rid of the line that sets $RESULT cos you don't need it anymore. </p>
<p dir="ltr">J<br>
</p>
<div class="gmail_quot<blockquote class=" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Jeremy,<div><br></div><div>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.</div><div><br></div><div>--------------------</div><div><div>#!/bin/bash</div><div><br></div><div>LOGFILE=/tmp/cron_list.log</div><div><br></div><div>cat /var/spool/cron/root > /tmp/cron_list.log</div><div><br></div><div>if [ -f /var/spool/cron/cworks ]; then</div><div>echo "================================" >> /tmp/cron_list.log</div><div><br></div><div>cat /var/spool/cron/cworks >> /tmp/cron_list.log</div><div><br></div><div>else echo ""</div><div>fi</div></div><div>-----------------------</div><div><div>#!/bin/sh                                                                                              </div><div>#                                                                                                      </div><div># Standard XYMON stuff                                                                                 </div><div>#                                                                                                      </div><div>if [ "$XYMONHOME" = "" ]; then                                                                         </div><div>   echo "XYMONHOME is not set... exiting"                                                              </div><div>   exit 1                                                                                              </div><div>fi                                                                                                     </div><div>                                                                                                       </div><div>if [ ! "$XYMONTMP" ]; then                                                                             </div><div>   . $XYMONHOME/etc/bbdef.sh                                                                           </div><div>fi                                                                                                     </div><div>                                                                                                       </div><div>                                                                                                       </div><div>#-----------------------                                                                               </div><div># EDIT Variables here                                                                                  </div><div>#-----------------------                                                                               </div><div>TEST=crontab</div><div>COLOR=green</div><div>LOGFILE=/tmp/cron_list.log</div><div>TMPFILE=$XYMONHOME/tmp/$TEST.tmp</div><div><br></div><div>RESULT=`cat $LOGFILE`</div><div><br></div><div><br></div><div>LINE="status $MACHINE.$TEST $COLOR `date`</div><div><br></div><div>$RESULT"</div><div><br></div><div>$XYMON $XYMSRV "$LINE"</div><div><br></div><div>#rm -f $BBTMP/$TEST.tmp</div><div><br></div><div>#rm -f $TMPFILE</div></div><div>-------------------------------------</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 4, 2015 at 6:54 PM, Jeremy Laidman <span dir="ltr"><<a href="mailto:jlaidman@rebel-it.com.au" target="_blank">jlaidman@rebel-it.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">Ben</div><div class="gmail_quote"><br></div><div class="gmail_quote"><span>On 5 February 2015 at 13:03, Benjamin Smith <span dir="ltr"><<a href="mailto:lists@benjamindsmith.com" target="_blank">lists@benjamindsmith.com</a>></span> wrote:<br><div> </div></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><span style="font-size:12.8000001907349px"># cat crontab files to </span><span style="font-size:12.8000001907349px">/tmp/cron_list.log for xymon crontab.sh</span></span><div style="overflow:hidden">0 * * * * /root/bin/std/show_crontab.sh??#XYMON?#?</div></blockquote></div><br>What does this script (show_crontab.sh) do?</div><div class="gmail_extra"><br></div><div class="gmail_extra">Cheers</div><span><font color="#888888"><div class="gmail_extra">Jeremy</div></font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr">John Palys<div>School Pathways, Inc.<br><a value="+15308310823" style="color:rgb(17,85,204)">866-200-6936 #2010 <u> Office</u></a><br><br></div></div></div>
</div>
</div>