different notification email

Matthew Macdonald-Wallace lists at truthisfreedom.org.uk
Wed Jun 18 10:00:30 CEST 2008


On Tue, 17 Jun 2008 17:47:17 +0200
Wim De Geeter <wim.de-geeter at uni-graz.at> wrote:

> Hi,
> 
> I have a small question. Is it possible to use different email
> templates for notification. One for warning and critical and another
> one for recovery.

Short answer: yes.

How would you do it?  As follows:

When nagios calls the alert program, it passes a number of
parameters.  One of these $NOTIFICATIONTYPE$ is described as follows in
the docs:

Notification Macros:
$NOTIFICATIONTYPE$ 	A string identifying the type of
notification that is being sent ("PROBLEM", "RECOVERY",
"ACKNOWLEDGEMENT", "FLAPPINGSTART" or "FLAPPINGSTOP").

Knowing this, you could write your own script in bash/python/etc. that
could be called as follows:

/usr/local/bin/alertscript.sh $NOTIFICATIONTYPE$ $HOSTNAME$ $MORE$
$MACROS$ $HERE$

In the script you could then check for the first argument and
depending on the value, send the appropriate email.

Personally, I have two templates for emails - Hosts and services - that
have tags in them similar to html such as <hostname> and
<servicename>.  I have a python script that is called by nagios in the
event of an alert and this script reads in the alert type
(host/service) and uses the appropriate template accordingly - there's
no reason why you couldn't do something similar based on the
notification type.

Hope this helps,

Matt
-- 
Matthew Macdonald-Wallace
matthew at truthisfreedom.org.uk
http://www.truthisfreedom.org.uk

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list