Safetynet installation & configuration instructions
---------------------------------------------------

There is by no means any one way to install this program. The
instructions provided here are simply meant to be a guide line and
can be strayed from a little bit or a lot. Play with the config,
make it work to fit into your environment as opposed to the otherway
around.


(1) Main configuration
----------------------
After you initally unpack the archive the first thing that you
should do is open the main script 'safetynet' in a text editor and
change the config values at the top of the script to match your
setup. Those values are explained here:

$conf_file
This is the configuration file. The default location is in the /etc
directory, but it can be placed anywhere as long as this variable
matches that location.

$state_dir
This is where you will set jobs to become ignored, or admin'd down.
It needs to be a directory as you will simply touch a file named the
process id that safetynet looks for. For example if $state_dir is
/var/state/safetynet (the default) and you have a job named Apache
that watches the process named 'httpd' you would
'touch /var/state/safetynet/httpd' and whenever safetynet would run
the Apache job would be skipped untill you 'rm' the above file. If
your job is looking for parameters and has any non-alpha in it like
'faxgetty cua/b 1', it would be changed to 'faxgetty_cua_b__'.
The one final option for the $state_dir operations is the 'ALL'
function. If you touch $state_dir/ALL it will down the entrie list
of processes to to watch.

$mail_prog
This is what should be run whenever a mail should be sent about a
non existant process that safetynet finds. By default this is
/bin/mail which should work for most setups, some people may need
to change this to /usr/bin/sendmail. The only requirements for this
option is that it needs to be able to deliver mail (if you leave it
set to mail 'root' it only needs to preform local delivery).

$mail_opts
Any special options you wish to pass to $mail_prog. Defaults to "".

$mail_to
Who should the status mails be going to. Defaults to "root".
A quick note about the whole mail setup, mail is only sent when a
process is found dead, this way if it runs every 10m you don't get
mail every 10m.

$ps_cmd
This is probably the most important thing of all. This is the command
to run to generate a listing of the processes on the system. There is
a good bit of flexability here in what to watch, for instance it by
default is set to "ps -Af" which on a linux system generates the 
process list so that each process contains command lines passed to it
as well such as "[...] /usr/bin/X11/X -auth /var/gdm/:0.Xauth :0" this
gives you the ability to check against command lines. However, the 
problem that arises here is that not all versions of 'ps' take the same
arguments, for instance on a solaris box it would be ideal to set this
variable to "ps -aux".
Play around with ps find out what works for you, also just because this
is call $ps_cmd it doesn't need to be 'ps' it could be any program as
long as it reports running processes.


(2) File setup
---------------
As root;
Move the script and the configuration file to the appropriate locations.

cp safetynet /usr/sbin
cp safetynet.conf /etc

And set the permissions accordingly.

chown root /usr/sbin/safetynet
chmod 700 /usr/sbin/safetynet
chmod 644 /etc/safetynet.conf


(3) Configuration
------------------
The configuration file is very simple and easy to follow and comes with
working examples so it should be no problem to setup your own entries.
Here is a run down of the configuration file.

job <friendly name> {
	<process name>;
	<command to restart>;
	[failure command];
	[pass command];
}

<friendly name>
A name to which the job is refered to as, for instance you could use
Apache here.

<process name>
The process ID to look for in the output of $ps_cmd (see (1)). httpd
for instance.

[failure command]
A command to run if the process is found dead and couldn't be restarted.
For instance: echo "httpd is dead!" | /bin/mail root

[pass command]
A command to run if the process is found dead but was restarted.
For instance: echo "httpd was dead, it's alive again" | /bin/mail root

Fields enclosed in <>'s are manditory. Those in []'s are optional.


At this point it's a good idea to run the script to make sure everything
is in order. Kill a process on purpose and make sure the script restarts
it etc...


(4) Cron Setup
---------------
The last thing you will want to do is add a cron job to run it every X
minutes. As root run 'crontab -e' to edit the crontab file for root. An
example entry would be:
0,15,30,45 * * * * /usr/sbin/safetynet --cron

This would cause the script to be run every 15m which is a pretty safe
interval.


(5) You done
-------------
Walk away from the machine knowing your processes are in good hands.
(This was a shameless plug).
