help-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Number of files in a directory?


From: Tim Nelson
Subject: Re: Number of files in a directory?
Date: Tue, 15 Mar 2005 14:12:48 +1100 (EST)

On Thu, 10 Mar 2005, nathan r. hruby wrote:

On Fri, 11 Mar 2005, Tim Nelson wrote:

----BEGIN SNIP
classes:
        # See if we're overlimt
        MailqueOverLimit = ( ReturnsZero(/bin/sh -c "expr `ls
        /var/spool/mqueue/ | grep q.*| wc -l`  \> 12 > /dev/null") )

Couldn't you use the control section to set a variable to the number of whatevers (files), and then set the class based on that? It'd also allow you to use the variable in the alerts to say how many there are.


Yah, but control: gets evaluated before classes (true)?  How does one do
this without running classes: twice?  I'm still a newbie, care to share an
example of how to do this?

/usr/bin/test `find /var/spool/mqueue -type f -name 'q*' | wc -l` -ge 12
> ----BEGIN SNIP
> classes:
>     # See if we're overlimt
>     MailqueOverLimit = ( ReturnsZero(/bin/sh -c "expr `ls
>     /var/spool/mqueue/ | grep q.*| wc -l`  \> 12 > /dev/null") )

control:
        MailQueueCount = ( ExecResult(find /var/spool/mqueue -type f -name 'q*' 
| wc -l )

classes:
        MailqueOverLimit = ( ReturnsZero(/usr/bin/test $(MailQueueCount) -ge 
12) )

Warning; completely untested, but it hopefully indicates the way I was thinking. Mark, does this mean that boolean operations would be a good idea in cfengine?

Most of the time cfengine is easy, but sometimes I just think like it's
p{erl,php,dksh} :)

pphp? :). I know the feeling. I'm not always sure I'm thinking cfenginely myself.

Hmm. If I were doing it, I'd make a shell script. Of course, that would mean that alerts wouldn't work. I might also try a cfengine method.


Hmm.. I'm trying to reduce the scripties.  We have one that does this now,
in fact we have like 6 :)

:). Now you know why I have a management system for them (see cfengine-masterconf, on arpmats.sourceforge.net).

        :)

--
Tim Nelson
Server Administrator
WebAlive Technologies Global
Level 1 Innovation Building, Digital Harbour
1010 LaTrobe Street
Docklands, Melbourne, Vic, 3008
Phone: +61 3 9934 0812
Fax: +61 3 9934 0899
E-mail: tim.nelson@webalive.biz
http://www.webalive.biz/

"Your Business, Your Web, Your Control"




reply via email to

[Prev in Thread] Current Thread [Next in Thread]