<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.17092" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2><SPAN class=593411319-11012011>Although there has
been discussion in the past (<A
href="http://www.xymon.com/archive/2007/02/msg00047.html">http://www.xymon.com/archive/2007/02/msg00047.html</A>) about
a way to track numbers of files in a directory through the xymon client, no
working solution was posted (and the only one I found (<A
href="http://www.xymon.com/archive/2007/02/msg00079.html">http://www.xymon.com/archive/2007/02/msg00079.html</A>),
the author claimed it would work, but (a) it does not - variable should not
have a $ before it when you set it, and (b) the author gives no indication of
how it should be used). I had a use for this facility, and didn't
need the normal dir count that returns a size in KB (or whatever du returns on
your server), and did not want to write an ext script as that seemed to create
unnecessary load, so after several false starts, and finally having to read the
source code, I found a working solution, which was to write a script that output
the information in the same format as the du command and then redefine the du
command in xymonclient.cfg as per the two listings below.</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=593411319-11012011>Create filecount.sh
in the client/bin folder, chmod +x it, and replace the du command by
setting the DU environment variable in
client/etc/xymonclient.cfg...</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>[xymon@<SPAN
class=593411319-11012011>myServer</SPAN> client]$ cat
bin/filecount.sh<BR>#!/bin/sh<BR># Written by SebA 11/01/11<BR>#filecount=`ls $1
| wc -l`<BR># The following is more efficient, at least on CentOS 5: 'it will
show files immediately and it has no memory limitations.'<BR>#filecount=`ls -1
-U $1 | wc -l`<BR># Must be >=1, or Xymon will interpret the result as a
failure, so include . and .. (and 'hidden') files.<BR>filecount=`ls -a -1 -U $1
| wc -l`<BR># Ensure we have a tab between the number and the
pathname...<BR>echo "$filecount
$1"</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=593411319-11012011>That last line may
have been converted from a tab character, so replace the consecutive space
characters when you use it!</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>[xymon@<SPAN
class=593411319-11012011>myServer</SPAN> client]$ grep filecount
etc/xymonclient.cfg<BR>DU="$XYMONHOME/bin/filecount.sh" # Replace with my
filecount script. /Seb<BR></FONT></DIV>
<DIV><FONT><SPAN class=593411319-11012011><FONT face=Arial size=2>You can then
use dir as normal on the server in client-local.cfg and hobbit-clients.cfg
(sorry - my client is running newest xymon, while the server is running
hobbit). So you can use SIZE on the file-count where it would normally
work on the dir-size (du).</FONT></SPAN></FONT></DIV>
<DIV><FONT><SPAN class=593411319-11012011><FONT face=Arial
size=2></FONT></SPAN></FONT> </DIV>
<DIV><FONT><SPAN class=593411319-11012011><FONT face=Arial
size=2>----------------------------</FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=593411319-11012011></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=593411319-11012011>Of course, proper
client/server support, instead of overriding du would be better, but maybe
this will help someone until that happens, or maybe this will be the trigger for
that to happen. ;)</SPAN></FONT></DIV>
<DIV><FONT><SPAN class=593411319-11012011><FONT face=Arial
size=2></FONT></SPAN></FONT> </DIV>
<DIV><FONT><SPAN class=593411319-11012011><FONT face=Arial size=2>In the course
of my debugging, I was somewhat frustrated by the length of time changes took to
progagate from the server to the client (but I can live with this). What
would be routinely useful though is that even if the result is a green in
the files column, that it displayed what the criteria are (like it does if the
result is non-green)? Because it (hobbit-clients.cfg) is clearly cached by
the server and not checked when the client reports. (I believe
hobbit-alerts.cfg (or whatever it is called now) is checked when the client
reports, no? So they do not behave the same.) Anyway, this
caching means one does not know which criteria were used to determine a green
result. Plus, displaying it in the page would be more convenient as most
people don't have the file open in another window!</FONT></SPAN></DIV></FONT>
<DIV><SPAN lang=en-gb><FONT face=Arial size=2></FONT></SPAN> </DIV>
<DIV><SPAN lang=en-gb><FONT face=Arial size=2>Kind regards,</FONT></SPAN> </DIV>
<P><SPAN lang=en-gb><FONT face=Arial size=2><SPAN
class=593411319-11012011>SebA</SPAN></FONT></SPAN></P></BODY></HTML>
<P><FONT SIZE=2 FACE="Arial">Internal Virus Database is out of date.<BR>
Checked by AVG - www.avg.com<BR>
Version: 8.5.449 / Virus Database: 271.1.1/3243 - Release Date: 11/07/10 19:34:00<BR>
</FONT></P>