Forum: Cfengine Help
Subject: Re: number of cf-monitor processes
Author: neilhwatson
Link to topic: https://cfengine.com/forum/read.php?3,19125,19132#msg-19132


$ cf-agent -IKf ./montest.cf 
 !! Process count for 'cf-monitord' was out of promised range (0 found)
I: Report relates to a promise with handle ""
I: Made in version 'not specified' of './montest.cf' near line 17
I: Comment: Cfengine 3 environment monitor

 -> Making a one-time restart promise for cf-monitord
R: Would restart cf-monitord
$ ps -ef|grep cf-monitord
nwatson  27959 27854  0 11:42 pts/0    00:00:00 grep cf-monitord


Run again when I know cf-monitord is running.

$ cf-agent -IKf ./montest.cf 
 !! Matched: root     27983  0.1  0.0  15412  3844 ?        Ss   11:47   0:00 
/var/cfengine/bin/cf-monitord
$ cf-agent -IKf ./montest.cf 
 !! Matched: root     27983  0.0  0.0  15412  3848 ?        Ss   11:47   0:00 
/var/cfengine/bin/cf-monitord
$ cf-agent -IKf ./montest.cf 
 !! Matched: root     27983  0.0  0.0  15412  3848 ?        Ss   11:47   0:00 
/var/cfengine/bin/cf-monitord
$ ps -ef|grep cf-monitord
root     27983     1  0 11:47 ?        00:00:00 /var/cfengine/bin/cf-monitord
nwatson  28046 27854  0 11:48 pts/0    00:00:00 grep cf-monitord


So this promise will take action if one, and one only process is not found.  I 
see no provision to handle multiple instances.  No, cf-monitord does not spawn 
children.    You might try showstate to see what the agent sees at run time.  
http://www.cfengine.org/manuals/cf3-reference.html#showstate-in-reports


body common control {
    bundlesequence => { "test" };
    inputs => { "cfengine_stdlib.cf" };
}

bundle common agent {
    classes:
        "all" expression => "any";
}


bundle agent test {

        processes:
        "cf-monitord"
                comment => "Cfengine 3 environment monitor" ,
                process_count => check_range("cf-monitord" , "1" , "1") ,
                process_select => ps_owner("root") ,
                restart_class => "restart_cf_monitord";

        reports:

                restart_cf_monitord::
                        "Would restart cf-monitord";
}

body process_select ps_owner(owner)
{
process_owner => { "$(owner)" };
process_result => "process_owner";
}



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

Reply via email to