<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 14 June 2016 at 20:48, Becker Christian <span dir="ltr"><<a href="mailto:christian.becker@rhein-zeitung.net" target="_blank">christian.becker@rhein-zeitung.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">







<div lang="DE" link="#0563C1" vlink="#954F72">
<div>
<p class="MsoNormal"> <br></p>
<p class="MsoNormal"><span lang="EN-US">What I have:<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">I have a
<span>linux</span> client with <span>xymon</span> agents up and running, reporting his data to the
<span>Xymon</span> server -> this is working fine.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">This
<span>linux</span> client serves an application that creates 6 new different
<span>logfiles</span> every day -> that’s my problem.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">The names of the
<span>lofgiles</span> are like this: </span><span lang="EN-US" style="font-family:"Courier New";color:red">Log.File_ABC#_YYYYMMDD_######.log</span><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">The first
</span><span lang="EN-US" style="font-family:"Courier New";color:red">#</span><span lang="EN-US"> in the name could be numbers
<span>fom</span> 1 to 6.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US" style="font-family:"Courier New";color:red">YYYYMMDD</span><span lang="EN-US"> is the actual day date, like 20160414.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">The
</span><span lang="EN-US" style="font-family:"Courier New";color:red">######</span><span lang="EN-US"> block is another numeric identifier, like 050601 or similar, which also changes every day, but not
 following any rule.</span></p></div></div></blockquote><div><br></div><div>I believe this is exactly the sort of thing the backticks were designed for.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div lang="DE" link="#0563C1" vlink="#954F72"><div><p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal">What I want:<br></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">My goal is to check those
<span>logiles</span> for the keyword ERROR and let <span>
Xymon</span> go red if this keyword occurs.<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">What I’m looking for is the necessary
<span>config</span> on both the client (in </span><span><span lang="EN-US" style="font-family:"Courier New"">localclient.cfg</span></span><span lang="EN-US">) and the
<span>xymon</span> server (in </span><span lang="EN-US" style="font-family:"Courier New"">client-<span>local.cfg</span></span><span lang="EN-US"> and
</span><span><span lang="EN-US" style="font-family:"Courier New"">analysis.cfg</span></span><span lang="EN-US">) using
<span>regexp</span>.</span></p></div></div></blockquote><div><br></div><div>Nothing is required on the client.  localclient.cfg is not used if you're using centralised configuration.  Specifically, the comment at the top of localclient.cfg says "By default ... In that case, THIS FILE IS NOT USED and you should IGNORE it."  It's not 100% clear, but essentially, if you use centralised configuration, you don't use localclient.cfg on the client, and instead use client-local.cfg/analysis.cfg on the server.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div lang="DE" link="#0563C1" vlink="#954F72"><div><p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US"><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">I’m thinking about something like this to have in the
<span>linux</span> client’s </span><span><span lang="EN-US" style="font-family:"Courier New"">localclient.cfg</span></span><span lang="EN-US">:<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt;text-indent:35.4pt"><span lang="EN-US" style="font-family:"Courier New"">LOG `ls -1
<span>Log.File_ABC</span>*_`date +%<span>Y%m%d</span>\`_*.log`<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:35.4pt"><span lang="EN-US">But I’m not sure about the syntax here.</span></p></div></div></blockquote><div><br></div><div>That won't work due to the nested backticks.  You can have only one pair of backticks.</div><div><br></div><div>Also, you need a colon between LOG and the rest.  The very first example at the top of client-local.cfg shows:</div><div><br></div><div>log:FILENAME:MAXDATA</div><div><br></div><div>I don't think the MAXDATA is optional.</div><div><br></div><div>There are several ways to do what you want, by avoiding the backticks.</div><div><br></div><div>Option 1: Use a bash-ism, such as $(cmd) in place of `cmd`, like so:</div><div><br></div>log:`ls -1 /path/to/Log.File_ABC*_$(date +%Y%m%d)_*.log`:10240</div><div class="gmail_quote"><br></div><div class="gmail_quote">Option 2: Use a more inclusive wildcard match, and list the newest 6 files that match:</div><div class="gmail_quote"><br></div><div class="gmail_quote">log:`ls -1t /path/to/Log.File_ABC*_*.log | head -6`:10240</div><div class="gmail_quote"><br></div><div class="gmail_quote">Option 3: Use a script on the client to show the files:</div><div class="gmail_quote"><br></div><div class="gmail_quote">log:`/usr/local/bin/show-the-files`:10240</div><div class="gmail_quote"><br></div><div class="gmail_quote">Then in show-the-files, do whatever fancing file matching, testing, excluding, etc.  You can use this to show the last 6 files by date, but exclude files that are empty.  You can also construct the file matching string using the date, without it interfering with the backticks in the "log:" line.</div><div class="gmail_quote"><br></div><div class="gmail_quote">#!/bin/sh</div><div class="gmail_quote">DATE=`date +%Y%m%d`</div><div class="gmail_quote">MATCH="Log.File_ABC[1-6]_$DATE_??????.log"</div><div class="gmail_quote">LOGDIR=/path/to/log</div><div class="gmail_quote"><br></div><div class="gmail_quote">COUNT=0</div><div class="gmail_quote">for FILE in `ls -1t $LOGDIR/$MATCH`; do</div><div class="gmail_quote">    [ -s $FILE ] || continue # skip empty files</div><div class="gmail_quote">    echo $FILE</div><div class="gmail_quote">    let COUNT=$COUNT+1</div><div class="gmail_quote">    [ $COUNT -eq 6 ] && break</div><div class="gmail_quote">done</div><div class="gmail_quote"><br></div><div class="gmail_quote">J</div><div class="gmail_quote"><br></div></div></div>