Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Hi currently Nagios sends notifications from nagios@server.domain.com, How do I go about configuring this? Thanks

share|improve this question

6 Answers 6

In a default Nagios install, it's also defined in the "host-notify-by-mail" or "service-notify-by-mail" commands, which you'll find in commands.cfg. The default would be something like:

/bin/echo -e "$NOTIFICATIONTYPE$ - Service notification for $SERVICEDESC$ from host $HOSTNAME$ - $HOSTALIAS$\n$SERVICEDESC$: $SERVICEOUTPUT$\n" | /bin/mail -s '$NOTIFICATIONTYPE$/$SERVICESTATE$ - $HOSTNAME$/$SERVICEDESC$' $CONTACTEMAIL$

So just add a "-r sender@address" option to the mail command, and that should work.

share|improve this answer
    
That's what I did, and it worked fine. Different alerts actually get sent out by different accounts because of our automated ticketing program. –  breadly Oct 9 '09 at 17:25
    
I added this between /bin/mail and the -s –  jgritty 2 days ago

Couldn't get the "-- -r nagios@domain.com" solution to work. It turns out options after "--" are options for sendmail. Looking at sendmail options, it should be "-fnagios@domain" NOTE NO SPACE between -f and nagios@domain.com.

So the following is now working :-

  command_line    /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\Address: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$LONGSERVICEOUTPUT$" | /bin/mail -s "$SERVICESTATE$ - Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -- -fnagios@domain.com
share|improve this answer

I was able to do this by changing the command to something liek:

command_line /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTNAME$\Address: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$LONGSERVICEOUTPUT$" | /bin/mail -s "$SERVICESTATE$ - Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$ -- -r $ADMINEMAIL$

The magic is the '-- -r' part.

ADMINEMAIL is set in your nagios.cfg, but could be any email address for the 'From' address.

share|improve this answer

Both "-r nagios@company.com" and "-fnagios@company.com" worked for me.

The trick is to have these prefixed with " -- "

Thank you all for the tips.

share|improve this answer

None of the above works with current versions of Nagios and/or Postfix. The flag that needs to be added to the Nagios "host-notify-by-mail" or "service-notify-by-mail" commands in the file "commands.cfg" reads as follows:

-a "From: john.doe@uzh.ch"

Note that the quotation marks are essential!

share|improve this answer

As documented at http://nagios.sourceforge.net/docs/3%5F0/configmain.html you can set admin_email to the value you want in the from field.

share|improve this answer
    
This is demonstrably wrong. –  jgritty 2 days ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.