Hi Aleksey,

On 11/11/10 00:34, Aleksey Tsalolikhin wrote:
> check that CUPS (printer service) is running by checking the "ps" output, and
> if regex match for "cups" fails, restarting cups:
> 
> --- start cfengine config ----
> body common control
> 
> {
> bundlesequence  => { "check_cups_running"  };
> }
> 
> 
> ########################################
> 
> 
> bundle agent check_cups_running {
> 
> 
>     processes:
> 
>             "cupsd"
> 
>                 restart_class => "start_cups";
>                 # restart_class sets up a class if the regex match FAILS
> 
>     commands:
> 
>       start_cups::
> 
>                 "/etc/init.d/cups start";
> 
> }
> 
> --- end cfengine config file ---
> 
> It just occurred to me that a more reliable test would be to pretend
> to be a client for that service and to try to connect to it, and if it
> fails then to try to restart.  (more reliable because if there is
> another process in the process table, let's say a program called
> mycupsarefull, but cups is not running, cfengine will not proceed to
> restart CUPS)

This is a very interesting remark.

This bit me recently, and I have since become maniacal about always
using the full path name of an executable in processes promises, eg:

processes:
        "/usr/sbin/cupsd"
                etc

This avoids the "mycupsarefull" problem, and the
more-common-than-you'd-think "an administrator is running ps ax | grep
cupsd" problem.

Following your idea of pretending to be a client for that service, I
think this is a great scenario for a "usemodule" script.

However, this would obviously require writing scripts for many, many
services... So why not use what already exists? Monitoring systems
already have all these "test scripts".

An ideal way forward in my opinion would be for Cfengine to be able to
"know" what the monitoring perceives about a service, either from the
inside (I guess this is kind of cf-monitord's role, but could also just
be calling Nagios plugins locally), or from the outside by interacting
witht a monitoring system to get the current status (I recall that
Cfengine and Zenoss have some integration, but not really on this subject).

Just some thoughts... Would you consider this approach valid?

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

Reply via email to