The following Perl scripts are included as examples and helpful tools in your system administration package. If you do not have Perl, you should get it -- it is a very useful language for system administration.
It is useful to run cfengine on a daily basis from a cron
script.
Use a line like the following one to start cfengine each night. (Note the
curiosities of older BSD cronfiles).
0 0 * * * /usr/local/lib/cfengine-3.0/bin/cfwrap cfdaily
where cfdaily is a script which looks something like
#!/bin/sh CFINPUTS=/usr/lib/cfengine/inputs /usr/local/bin/cfengine
You will need to include full path names to the scripts in the cron file.
The syntax for using cfwrap
is as follows.
host% cfwrap mycommand host% cfwrap cfengine host% cfwrap script_which_sets_CFINPUTS_and_calls_cfengine
When you run cfengine it normally only generates output if something is
wrong which needs your attention. If you are running cfengine as a
cron
job then the results of each job are normally mailed back to
you -- or to root. But this causes problems in a networked
environment, since mail to root is usually redirected to some central
place which local system administrators cannot access. Moreover, you
have no way of knowing which host sent the information. The solution is
to use a script as a wrapper. The script simply executes some command
and collects the output from that command into a file which then gets
mailed to some address.
The address to be mailed to is obtained directly from cfengine by
calling it with the -a switch. The name of the host running
cfengine is prepended to the file before it is sent making it easy to
see where each message originated. This is also transferred to the
subject header of the mail message. cfwrap
calls cfmail
in order to mail the result of the command back to the system
administrator.
Because there are no standard mail-agents except for sendmail, the wrapper script cfwrap calls its own simple mail agent cfmail to send the message. Note that the flags variable in the script cfmail arranges for the mail message to be sent with a return address other than "root". This means that if the recipient of the mail should decide to hit `r' for `reply' to reply to the message, you have a chance of getting to see the message before it vanishes along with the rest of the mail to root into the same black hole that swallows up all those credit cards, house-keys and odd socks that disappear on a daily basis.
You might have to tweak the scripts slightly to tailor them to your own needs. They are used as follows:
host% echo test .... | cfmail -s "Test message" mark
Go to the first, previous, next, last section, table of contents.