version: cfengine community 3.1.0
os: debian

Can somebody confirm this that the calculation of used time of  process is 
wrong. I have have a promise that kills programs that used more then 15 minutes 
of cpu-time:

bundle agent test
{
        vars:
                any::
                        "exclude_owners"        slist =>  { "root", "ganglia", 
"daemon", "postfix", "nslcd", "ntp" };

        methods:

                LOGIN_HOST::
                        #"any" usebundle => sara_user_consume_resources("15", 
"1073741824", @(quarterly.exclude_owners));
                        # must use test.exclude_owners else we get undefined 
errors
                        #
                        "any" usebundle => sara_user_consume_resources("15", 
"7G", @(test.exclude_owners));

}


bundle agent sara_user_consume_resources(minutes, memory, exclude)
{
        processes:
                any::
                        ".*"
                                comment         => "Kill processes that use to 
much resources",
                                signals         => { "term", "kill"},
                                process_count   => check_range("user_procs", 
"0", "0"),
                                action          => policy("warn"),
                                process_select  => 
sara_user_consume_resources_select("$(minutes)", "$(memory)", @(exclude));
}

##
# Kill processes that uses too much cpu time or memory and exclude
# important users
#
body process_select sara_user_consume_resources_select(minutes, memory, owners)
{
        #command        => ".*";
        process_owner   => { @(owners) };
        ttime_range     => irange(accumulated(0,0,0,0,"$(minutes)",0), 
accumulated(1,0,0,0,0,0));
        rsize           => irange("$(memory)", 'inf');
        process_result  => "ttime.!process_owner";
}

This bundle matches process:
{{{
AddVariableHash(match.0=bas      15368  100  0.0   4740  1500 pts/8    R+   
14:53   3:47 ./memory 1 1 (string) rtype=s)
Searching for scope context match
Found scope reference match
CopyRvalItem(s)
Added Variable 0 at hash address 48 in scope match with value (omitted)
Setting local variable "match.0" context; $(0) = bas      15368  100  0.0   
4740  1500 pts/8    R+   14:53   3:47 ./memory 1 1
SelectProcess(bas      15368  100  0.0   4740  1500 pts/8    R+   14:53   3:47 
./memory 1 1)
SplitProcLine(bas      15368  100  0.0   4740  1500 pts/8    R+   14:53   3:47 
./memory 1 1)
Selection filter matched TIME/TIME = 3:47 in [900,31536000]
(14:53)
2010=2010,11=Nov,16,14,53
Time 14:53 CORRESPONDS Tue Nov 16 15:53:00 2010
}}}}

Note that 3:47: is 3 minutes and 47 seconds ===> 227 seconds and cannot be in 
the range 900 - 31536000
Or must i set other ps option?



--
Bas van der Vlies
b...@sara.nl



_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to