Forum: CFEngine Help
Subject: Re: managing cf-execd children
Author: [email protected]
Link to topic: https://cfengine.com/forum/read.php?3,22992,22994#msg-22994
I had the same problem.. So, I did this... Notice the count on cf-agent.
Also, instead of just aborting execution of cf-agent, I actually wanted a
notification that things were piling up. If I just aborted, the reports didn't
print...
Soo.... I kind of hacked around it. I execute a command: promise to send a
email to an "alert" address that humans are watching. I could have used a
report: promise, but that would have ended up to the same mailing list that all
my other reports go to.
I figured that this was so critical, that I wanted a lot of eyeballs seeing
what was causing the pile up.
bundle agent cfengine_automated_execution
{
vars:
"root_crontab_entry" string => "#
# Entry to run cf-execd in non-daemon mode hourly. This starts splaytime, not
execution.
0 * * * * /var/cfengine/bin/cf-execd -F";
processes:
"cf-serve"
handle => "verify_cf_serverd_is_running",
restart_class => "start_cf_serverd";
# We no longer cf-monitord. Its not providing any decent value to us, so shut
it down.
# "cf-monit"
# handle => "verify_cf_monitord_is_running",
# restart_class => "start_cf_monitord";
"cf-agent"
handle => "verify_cf_agent_doesnt_pile_up",
process_count => cfagent_executions;
commands:
start_cf_serverd::
"/var/cfengine/bin/cf-serverd";
#start_cf_monitord::
# "/var/cfengine/bin/cf-monitord";
linux_cron_restart_needed::
"/sbin/service crond restart";
solaris_cron_restart_needed::
"/usr/sbin/svcadm restart svc:/system/cron:default";
cfagent_haywire::
"/var/cfengine/modules/notify_cfengine_pileup.sh";
files:
# The primary crontab for root may not exist. If not, create it.
linux::
"/var/spool/cron/root"
create => "true",
perms =>
mog("0400","root","root"),
handle =>
"linux_insert_crontab_entry",
classes =>
if_repaired("linux_cron_restart_needed"),
edit_line =>
append_if_no_line("$(root_crontab_entry)");
sunos_5_10::
"/var/spool/cron/crontabs/root"
handle =>
"solaris_insert_crontab_entry",
classes =>
if_repaired("solaris_cron_restart_needed"),
edit_line =>
append_if_no_line("$(root_crontab_entry)");
methods:
cfagent_haywire::
"any" usebundle => abort_cfengine_execution();
reports:
(linux_cron_restart_needed|solaris_cron_restart_needed)::
"cf3: Entries for cf-execd placed in root's crontab. Executing
a restart of cron";
cfagent_haywire::
"cf3: Cfengine has gone crazy on $(sys.host). Aborting
execution and sending notification.";
}
####################################################################################
body process_count cfagent_executions
{
match_range => "1,5";
out_of_range_define => { "cfagent_haywire" };
}
####################################################################################
bundle agent abort_cfengine_execution
{
classes:
"stop_cfengine_execution" and => { "cfengine_3" };
}
In my promises.cf, I define this..
body agent control
{
....
# Define a class we can raise if we want to stop execution of cf-agent
abortclasses => { "stop_cfengine_execution" };
# Define a class we can raise if we want to stop and move onto the next
bundle (not all of cf-agent)
abortbundleclasses => { "stop_bundle.*" };
}
Hope that helps what you're trying to accomplish.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine