=cut

TITLE=alerter
DESCRIPTION=Figures out the appropriate templates to use to construct the alert text and triggers the appropriate alert-senders
KEYWORDS=alerter,alerts
DOCTOP=index
DOCPREV=alert-monitor
DOCNEXT=alert-email

=pod

=head1 alerter - construct and send alert text

=head2 Usage:

=exec ../alerter -h 2>&1

=head2 Description:

[C<Alerter> may be rolled into the C<alert-monitor> at some point in
the future.  It was easier to test as a separate program, and the performance
hasn't been an issue for me.]

C<Alerter> is passed its parameters (specified above) by the L<alert-monitor>.
Most of them are used to fill in information in the text of the alert.  The
interesting ones are C<towho> and C<template>.

It also reads the L<alert-destination-map config-file|configfile-alert-destination-map>
to decide where the alert needs to go.  This will give it a list of (method, address)
pairs.

For a given template-name, say C<xxx>, and method, say C<method>, it will 
look for files in @@CONFIGDIR@@/alert-templates, called:

	method-xxx
	method-DEFAULT
	xxx
	DEFAULT

and take the first one it finds.  Similarly, it will look for a header to add to the
top of the template called:

	method-HEADER
	HEADER

and a footer in one of:

	method-FOOTER
	FOOTER

The three pieces will be concatenated giving the template text.  Then substitutions
will be done for the following L<magic cookies|cookies>:

	HOST IP REALRRD WILDPART FIXEDRRD VAR STATUS OLDSTATUS
	VALUE RELATION THRESHOLD START DURATION HOSTDESC RRDDESC 
	NOW TEXTNOW ALERTHOST TOWHO WEBMASTER HTMLURL CGIURL HOSTINDEXURL

This gives the alert text.  From the method definition in the
L<alert-destination-map config-file|configfile-alert-destination-map>
C<alerter> knows which program to run to send the alert text to the
appropriate address, and it does it.

=head2 Alert-Sending Scripts

These are now easy to write, and in many cases you won't even have to
write one.  There are two requirements for an alert-sending script:

=over 4

=item 1) It must take an address to send to on the command-line, and

=item 2) It must accept the text on stdin.

=back 4

E.G. you could use sendmail with no wrapper.
