It is probably not a bug - it is a language (in)consistency. Well, maybe that's a bug... let's see what Mark says?
You are promising two contradictory things, and that is the basic problem. The first promise is that you will set a class "user_procs_out_of_range" if the number of processes matched by the promise topic ".*" is out of range 0..0. This will always happen. Every process that matches the name ".*" will always have something running. The second thing you are promising is that you will select processes which match the sub-constraint of "accumulated time of 15 minutes or more, not owned by root, ganglia, daemon..." If you combine the two, you restrict the processes which can be considered, but since all of them match ".*", you'll always set your class - even if the subconstraint limits the processes. If you want to match only those processes that are over 15 minutes, you need something like this: bundle agent example(lookfor) { processes: ".*" comment => "Kill processes that use to much resources", process_select => sara_user_consume_resources("$(lookfor)"), classes => if_ok("user_procs_out_of_range"); reports: user_procs_out_of_range:: "There are user procesees that consume too much resources"; } body process_select sara_user_consume_resources(what) { command => "$(what)"; process_owner => { "root", "ganglia", "daemon", "postfix", "nslcd" }; ttime_range => irange(15, accumulated(0,1,0,0,0,0)); process_result => "command.ttime.!process_owner"; } On Nov 12, 2010, at 4:32 AM, Bas van der Vlies wrote: > version: community edition 3.1.0 > os: debian > > I want to kill processes that have accumulated more then 15 minutes of time: > > body common control > { > bundlesequence => { example }; > > inputs => { > "cfengine_stdlib.cf" > }; > > } > > bundle agent example { > processes: > ".*" > comment => "Kill processes that use to much resources", > #signals => { "term", "kill"}, > process_count => check_range("user_procs", "0", "0"), > process_select => sara_user_consume_resources; > > reports: > user_procs_out_of_range:: > "There are user procesees that consume too much resources"; > } > > > body process_select sara_user_consume_resources > { > process_owner => { "root", "ganglia", "daemon", "postfix", "nslcd" }; > ttime_range => irange(15, accumulated(0,1,0,0,0,0)); > process_result => "ttime.!process_owner"; > } > > > > > =============== Output =================== > This promise will kill all processes that have consume time: -d2 output > {{{ > Added Variable 0 at hash address 48 in scope match with value (omitted) > Setting local variable "match.0" context; $(0) = ntp 1743 0.0 0.0 > 28244 1712 ? Ss Oct27 0:13 /usr/sbin/ntpd -p /var/run/ntpd.pid > -g -u 108:111 > SelectProcess(ntp 1743 0.0 0.0 28244 1712 ? Ss Oct27 > 0:13 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 108:111) > SplitProcLine(ntp 1743 0.0 0.0 28244 1712 ? Ss Oct27 > 0:13 /usr/sbin/ntpd -p /var/run/ntpd.pid -g -u 108:111) > Selection filter matched TIME/TIME = 0:13 in [15,2592000] > }}} > To my knowledge is only consumed 13 minutes of time > > {{{ > Added Variable 0 at hash address 48 in scope match with value (omitted) > Setting local variable "match.0" context; $(0) = bas 27053 0.4 0.0 > 10860 1296 pts/3 S+ 13:12 0:04 top -d 1 > SelectProcess(bas 27053 0.4 0.0 10860 1296 pts/3 S+ 13:12 > 0:04 top -d 1) > SplitProcLine(bas 27053 0.4 0.0 10860 1296 pts/3 S+ 13:12 > 0:04 top -d 1) > Selection filter matched TIME/TIME = 0:04 in [15,2592000] > }}} > This consumes only 4 minutes > > =============================================================== > > Is there something wrong with the bundle or is this a bug? > > regards > > > > -- > ******************************************************************** > * Bas van der Vlies e-mail: b...@sara.nl * > * SARA - Academic Computing Services Amsterdam, The Netherlands * > ******************************************************************** > _______________________________________________ > Help-cfengine mailing list > Help-cfengine@cfengine.org > https://cfengine.org/mailman/listinfo/help-cfengine _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine