Different sender address for recoveries vs alerts

Justin T Pryzby justinp at norchemlab.com
Sun Jan 13 00:51:18 CET 2013


It looks like you've already got the mail command?  You just need to
specify two nagios commands, one for failures, and one for recoveries,
and use escalations for your text alerts, instead of in the service.
Alternately, you could specify two contacts for every service
(probably in a template), one for failures, and one for recoveries.
The recovery contact can specify a different
host/service_notification_commands.

*alternately*, you dynamically update the sender address based on the
HOSTSTATE (or such), probably in a shell script:
fromaddr=$fail_addr
[ "$HOSTSTATE" = OK ] && fromaddr=$fail_addr
...

Note that either requires setting nagios enable_environment_macros, or
otherwise getting HOSTSTATE into the script (command line options,
environment variables specified in the command_line, like
	command_line HOSTSTATE=$HOSTSTATE$ \
		SERVICESTATE=$SERVICESTATE$ \
		/usr/local/sbin/nagios-alert

If I misunderstood, and you're trying to get the from address, then
the following applies:

sendmail -f specifies (or overrides) the SMTP envelope-sender, and
mail(1) (at least for bsd-mailx from debian) has:

     mail [-dEIinv] [-a header] [-b bcc-addr] [-c cc-addr] [-s subject]
          to-addr ... [-- sendmail-options ...]

So I use mail -- -f nagios at loki to 1) make the "from" string shorter
in text messages; and, 2) use postfix sender_dependent_relayhost_maps
to avoid our usual relayhost for nagios alerts.

Justin

On Fri, Jan 11, 2013 at 08:50:47PM +0000, Aharon Verno wrote:
> I'm currently running Nagios v3.3.1 and have been trying to find a
> way to set different sender addresses for recoveries and alerts.  I
> was wondering if there's an option that I overlooked that lets you
> easily do this.  An example of my notification string for a page is
> this:
> 
> /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\nDate/Time: $LONGDATETIME$\n" \
>                                   | /bin/mail \
>                                     -s "$NOTIFICATIONTYPE$: Host: $HOSTNAME$ - $HOSTSTATE$" $CONTACTEMAIL$ -- \
>                                     -f <email_address>
> 
> The thought is to change the sender address so that when pages come
> through in the middle of the night the recovery page can be set to a
> non-obnoxious tone since that one doesn't need to wake you up.  If
> anyone has done something like this before please let me know and if
> there's some documentation on how to do it somewhere that would be
> great.

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. SALE $99.99 this month only -- learn more at:
http://p.sf.net/sfu/learnmore_122912
_______________________________________________
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