Got it, Jerome, thanks for letting me know the background here.

You can link promises using if_repaired -- so if snmpd.conf changes,
use if_repaired to set a class; another promise can fire off a command
(starting snmpd) if that class is set.

Aleksey



On Wed, Sep 21, 2011 at 8:52 AM, Jerome Yanga <jya...@esri.com> wrote:
> Thank you, Aleksey.  I will try this and provide an update.
>
> The reason why I would like to create such a configuration change is so that 
> I can make sure that servers that are not being monitored via SNMP are at 
> least configured to be monitored so that the next SNMP discovery will pick up 
> the servers that do not have its SNMP configured and started.  What I didn't 
> include in my previous email is that I perform a copy of snmpd.conf into 
> servers that may not have it.  This is the case for starting the process as 
> well as making sure that it will start again when the server is rebooted.
>
> In the case of the restart, I would like the process to restart when 
> snmpd.conf changes.
>
> jerome
>
> -----Original Message-----
> From: Aleksey Tsalolikhin [mailto:atsaloli.t...@gmail.com]
> Sent: Tuesday, September 20, 2011 11:08 PM
> To: Jerome Yanga
> Cc: help-cfengine@cfengine.org
> Subject: Re: CFEngine Help: how to start a service and make sure it runs 
> after a reboot
>
> On Fri, Sep 16, 2011 at 4:44 PM, Jerome Yanga <jya...@esri.com> wrote:
>> Hi!
>>
>> I am trying to replicate the following commands in a promise.  I have tried 
>> the restart_class but I cannot seem to get it working the way I have 
>> described below.
>>
>> service snmpd start/restart
>> chkconfig snmpd on
>>
>> I want it to restart snmpd if it is already running and start it if it is 
>> stopped.
>
> Why, please?  (I want to understand the use case.)
>
>
> Ok, so you want to:
>
> Check if the process is running, and based on that set a class PROCESS_RUNNING
>
> if PROCESS_RUNNING, then restart it
>
> if not PROCESS_RUNNING, then start it
>
> Right?
>
> Try this on for size (tested with sendmail daemon, it does work):
>
> bundle agent example
>
> {
> processes:
>
>  ".*"
>
>    process_count   => anyprocs,
>    process_select  => proc_finder;
>
>
> commands:
>
>  process_running::
>
>   "/bin/echo restart command";
>
>  process_not_running::
>   "/bin/echo start command";
>
> }
>
> ########################################################
>
> body process_select proc_finder
>
> {
>
> command => "sendmail: .*"; # (Anchored) regular expression matching
> the command/cmd field of a process
>
> process_result => "command";
>
> }
>
> ########################################################
>
> body process_count anyprocs
>
> {
> match_range => "0,0"; # Integer range for acceptable number of matches
> for this process
>
>
> out_of_range_define => { "process_running" }; # List of classes to
> define if the matches are out of range
>
> in_range_define => { "process_not_running" }; # List of classes to
> define if the matches are in range.
>
>
> }
>
>
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to