<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 28 October 2014 09:58, Bill Arlofski <span dir="ltr"><<a href="mailto:waa-hobbitml@revpol.com" target="_blank">waa-hobbitml@revpol.com</a>></span> wrote:<br><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"><div id=":24s" class="" style="overflow:hidden">Other ideas?   Can I somehow hammer this square peg into a round hole?<br></div></blockquote></div><br>You can create a dynamic file based on the logfile, and alert on that.  For example, in client-local.cfg, something like this:</div><div class="gmail_extra"><br></div><div class="gmail_extra">log:`LOG=/tmp/zlic.status; M=$(date +%M); [ $(expr $M % 10) -ge 5 ] && rm -f $LOG; grep "<span style="font-family:arial,sans-serif;font-size:13px">ArchivingAccountsLimit exceeded" /var/log/messages >> $LOG; [ -s $LOG ] && echo "$LOG"`:4096</span></div><div class="gmail_extra"><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div class="gmail_extra"><font face="arial, sans-serif">I'm assuming that /var/log/messages is rotated daily.  What happens here is that zlic.status will get the log entries from your current messages file (updated every 5 minutes) appended to it.  If there are no log entries, then the filename is not echoed and Xymon will ignore it (and no alerts possible).</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">The trick here is that the zlic.status file is emptied only every second run (every 10 minutes) prior to appending the log entries. By shrinking the file size, logfetch thinks the file has been rotated, zeroes its status, and starts looking at the file from the beginning.</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">Note that if you get a log entry in your messages file just prior to rotation, then you'll only get an alert between the time the message is detected and the messages file is rotated, which could be only a few minutes, or even not at all if the timing isn't favourable.  So in other words, this will generate an alert that persists until the next rotation of messages, or messages in the last 0-24 hours.  If you want to go for longer than that, you could perhaps grep from the current and previous messages file, so you're alerting on any messages in the last 24-48 hours.</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">Another way to do this is to use a "file:" definition, similarly creating a status file and then alarming on the file's size (non-zero indicating an alertable log entry).  For example:</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">file:`LOG=/tmp/zlic.status; grep "ArchivingAccountsLimit exceeded" /var/log/messages >> $LOG; echo $LOG`</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">Then in analysis.cfg, create a matching entry and alert on size>0.  A down-side to this approach is that you get a particularly unhelpful message along the lines of "FILE /tmp/zlic.status red size >0".</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">A third and similar way to do this is to create a file that exists only if the licencing log is not detected.  Like so:</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">file:`LOG=</font><span style="font-family:arial,sans-serif">/tmp/zlic.OK; </span><span style="font-family:arial,sans-serif">grep "ArchivingAccountsLimit exceeded" >/dev/null && rm -f $LOG || touch $LOG; echo $LOG`</span></div><div class="gmail_extra"><span style="font-family:arial,sans-serif"><br></span></div><div class="gmail_extra"><span style="font-family:arial,sans-serif">Then in analysis.cfg, create a matching entry and alert on "noexist".</span></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">Yet another way to do this is to use a pseudo-file to generate a status message.  For example:</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">file:`COL=green; MSG="licencing OK";  LOGS=$(</font><span style="font-family:arial,sans-serif">grep "ArchivingAccountsLimit exceeded" /var/log/messages); [ "$LOGS" ] </span><span style="font-family:arial,sans-serif">&& { COL=red; MSG="licencing error"; }; echo "status ${MACHINE}.zlic $COL $(date) $MSG" | $XYMON $XYMSRV @`</span></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">There is no output from this pseudo-file, so Xymon will not take any "file" connotations from it and will simply ignore it, except for the side-effects from the $XYMON command that's also run here.  This is tantamount to having a client-side ext script, and you may simply prefer to do that.  But this can be deployed centrally.</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">A few notes:</font></div><div class="gmail_extra"><font face="arial, sans-serif">1) None of these specific examples have been tested, and may contain syntax errors, but scriptlets like these have been used on production systems.</font></div><div class="gmail_extra"><font face="arial, sans-serif">2) I deliberately avoided using colons and backticks, because they are interpreted by the logfetch binary, and break the scriptlets.</font></div><div class="gmail_extra"><font face="arial, sans-serif">3) These scriptlets take up to 15 minutes to start reporting after being added to client-local.cfg.  When I'm testing these sort of things, I like to bring up a xymoncmd shell, and paste in the bits between the backticks, and look for errors or unexpected output.</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div><div class="gmail_extra"><font face="arial, sans-serif">J</font></div><div class="gmail_extra"><font face="arial, sans-serif"><br></font></div></div>