I have just written a promise which checks for the ntpd and starts if it
is not running. I know there are more elegant solutions, but I know that
this example works:
15 bundle agent check_service_running {
16
17 vars:
18 "service" slist => {"ntp"};
19 "daemon_path" string => "/etc/init.d";
20
21 processes:
22
23 # buildserver::
24 "$(service)"
25 comment => "Counting amount of processes for
'$(service)'",
26 process_count => up("$(service)");
27
28 commands:
29
30 "${daemon_path}/${service}"
31 comment => "Executing command '${daemon_path}/${service}
start'",
32 ifvarclass => "${service}_up",
33 args => " start";
34 }
35
36 body process_count up(s) {
37
38 match_range => "0,0";
39 in_range_define => {"$(s)_up"};
40 ifelapsed => "1";
41 }
Note that you may want to add a bundlesequence to the file. I don't need
one since this check is called from the bundlesequence inside my
promise.cf. For testing purposes I have set 'ifelapsed' to 1 which may not
be what is needed in a production environment. You may add more services
to the line ' "service" slist => {"ntp"};' and it should work, as long as
the service may be started with '/etc/init.d/SERVICENAME start'. I didn't
check it so far, so just try.
Bernd
Bernd Adamowicz | R&D BasisTechnology
Tel.: +49 (0) 6227 385 332 82 | Fax: +49 (0) 6227 385 588
[email protected] | www.icw.de | www.lifesensor.com
From:
Aleksey Tsalolikhin <[email protected]>
To:
cfengine <[email protected]>
Date:
15.12.2009 08:26
Subject:
need simple examples of cfengine3
Sent by:
[email protected]
I am working on an article to introduce more sysadmins to cfengine 3,
and I need help from the cfengine community putting together working
standalone examples of the power and simplicity of cfengine 3.
By standalone, I mean I should be able to run "cf-agent -f
example1.cf" and have example1.cf be the only file in
/var/cfengine/inputs, and have it work.
Here is what I would like to see:
1. Make sure /proc/sys/vm/swappiness is set to 0 on Linux servers.
2. Make sure root crontab contains an entry for "0 0 * * *
/sysadmin/nightly.sh"
3. Make sure ntpd and snmpd are running.
4. Alert an alert if any mounted filesystem exceeds 75% utilization.
5. Alert if there is any account with uid 0 other than root.
That should be enough, I don't want to overwhelm my readers with too
many examples.
I am going to work on coding these up, but if you already have some
working code that does this, please let me know.
Thanks,
Aleksey
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine
InterComponentWare AG:
Vorstand: Dr. Lutz Kleinholz (Vors.), Dr. Georg Ralle, Jörg Stadler /
Aufsichtsratsvors.: Prof. Dr. Christof Hettich
Firmensitz: 69190 Walldorf, Industriestraße 41 / AG Mannheim HRB 351761 /
USt.-IdNr.: DE 198388516 _______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine