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: Wed, 16 Mar 2005 15:47:40 +1100 (EST)

On Tue, 15 Mar 2005, Mark Burgess wrote:

On Tue, 2005-03-15 at 09:42 -0500, nathan r. hruby wrote:
On Tue, 15 Mar 2005, Mark Burgess wrote:


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?

I don't know what you mean by a boolean operation.

        Sorry; boolean was the wrong word; what was I thinking?  :)

Well, at least a few additional "operators" like "less than" or "greater
than" which return true/false to set a class to prevent this kind of
senseless abuse of fork() :)

control:
        x = ( ExecResult( something-big ) )
        y = ( ExecResult( something-small ) )

classes:
        XisBiggerThanY = ( GreaterThan( $(x) $(y) ) )

Yeah, this looks perl-esque, but I think a few extra operators would be
handy (We already have a substr() ).. I see there are already tests like
this in the cmp= operator for packages: and bymatches= for processes: so
it might make sense to refactor that code into something for more general
use?

Ah - I see. Yes, this is easily added. There are things like strcmp
already, but tell me what you want and I'll try to add them before next
release.

        Well, the obvious ones would be:

< > <= >= == != <=>

(stolen blatantly from man perlop). We can already use Strcmp for == and ! Strcmp for !=. Also, <= can be simulated via ! > and >= via ! <. Also, it doesn't seem to me that <=> is particularly useful in the cfengine situation (and it can be simulated with the others). That leaves:

< >

        Or if you prefer named operators: le ge

        Or using Nathan's suggestion: LessThan, GreaterThan

I prefer the symbolic ones (being a Perl-type guy), but Nathan's operators look more cfenginely.

        :)

--
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]