Change_Email_From

James Moseley jmoseley at corp.xanadoo.com
Wed Jan 19 05:51:53 CET 2011


There is no global method (that I know of) to simply set a from/reply-to
address in the Nagios config.  By default, email is sent from Nagios using
the /bin/mail program which will set the from/reply-to address as <user
calling the mail program>@<machine.name>.  In most cases, Nagios is running
under the user 'nagios'.

In your commands definitions, you can certainly alter your notifications to
move away from the Nagios default configuration which pipes notification
output to the following example:

/bin/mail -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $CONTACTEMAIL$

In order to set a from/reply-to address, you will need to use a mailer that
will allow you to set a from/reply-to address.  With /bin/mail, I don't
think that's possible.  Therefore, you'll need to use a program like
/usr/sbin/sendmail.  But sendmail uses a completely different syntax than
mail, so you can't just substitute /usr/sbin/sendmail for /bin/mail in your
Nagios config.

In a nutshell, to use sendmail you need to pipe in output containing the To,
From, Subject, etc, then the message, all on separate lines.  In order to do
this using printf, you would need to separate each line with "\n" new line
arguments.

As for the question about setting up a different from addresses depending on
host/service, you would simply create multiple notification commands, or you
could possibly use macros.

Perhaps I'm way off base here and there is an easier way to accomplish what
you guys want...  There are most likely several ways to skin this cat, like
using a mailer other than sendmail.

-- 
James Moseley


On Tue, Jan 18, 2011 at 3:49 AM, Mister IT Guru <misteritguru at gmx.com>wrote:

>  On 18/01/2011 09:33, Rajesh Kumar wrote:
>
>  Hi All
>
>
>       I used Nagios Core in my CentOS Server. It’s working fine. I need to
> change notification alert from my mail id. Now am getting mail id from
> nagios at monitor.server The monitor.server is my CentOS host id. How to
> switch to my mail id, (ras.kumar01 at gmail.com) in nagios.
>
>
> Regards
>
> B.Rajeshkumar
>
> +1 -- I have a similar requirement, but I'd like to use multiple from
> addresses, for for different services or hosts.
>
> --
> The Solo System Admin - Follow me - I follow youhttp://solosysad.blogspot.com/
> Latest Entry: Bacula - Building from source
> --
> Mister IT Guru At Gmx Dot Com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20110118/cf844f65/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
-------------- next part --------------
_______________________________________________
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