Change email address

Hi

I want that nagios send mails with a different domain. Now nagios uses my hostname, i want to change it, is it possible?

Within a command definition for notifications in commands.cfg, you can edit the command line and after /usr/bin/mail command use -a swtich with From: field, like this:

and the message will come from specifeid From: address

Be aware that if you will be upgrading Nagios, this file will be overwritten, so it is advisable for you to create a new file with custom notification command and specify it in nagios.cfg. Otherwise be sure to backup your config and bring it back when upgrade is done…

[quote=“Albin”]Within a command definition for notifications in commands.cfg, you can edit the command line and after /usr/bin/mail command use -a swtich with From: field, like this:

and the message will come from specifeid From: address

Be aware that if you will be upgrading Nagios, this file will be overwritten, so it is advisable for you to create a new file with custom notification command and specify it in nagios.cfg. Otherwise be sure to backup your config and bring it back when upgrade is done…[/quote]

Thank you.
Is this the line that i have to mdify?

‘notify-host-by-email’ command definition

define command{
command_name notify-host-by-email
command_line /usr/bin/printf “%b” "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState:
$HOSTSTATE$\nAddress: $$
}

Yes, but I think your command_line look somehow too short and uncomplete. This is how it should look like, check again.

‘host-notify-by-email’ command definition

define command{
command_name host-notify-by-email
command_line /usr/bin/printf “%b” “***** Nagios ***\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTALIAS$\nState: $HOSTSTATE$ for $HOSTDURATION$\nAddress: $HOSTADDRESS$\nInfo:\n\n$HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nACK by: $HOSTACKAUTHOR$\nComment: $HOSTACKCOMMENT$\n" | /usr/bin/mail -s " $NOTIFICATIONTYPE$ alert $NOTIFICATIONNUMBER$ - $HOSTALIAS$ host is $HOSTSTATE$ **” $CONTACTEMAIL$
}

You have to modify the blue part, like this (add the red bolded italics) part:

‘host-notify-by-email’ command definition

define command{
command_name host-notify-by-email
command_line /usr/bin/printf “%b” “***** Nagios ***\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTALIAS$\nState: $HOSTSTATE$ for $HOSTDURATION$\nAddress: $HOSTADDRESS$\nInfo:\n\n$HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n\nACK by: $HOSTACKAUTHOR$\nComment: $HOSTACKCOMMENT$\n" | /usr/bin/mail -a "[email protected]" -s " $NOTIFICATIONTYPE$ alert $NOTIFICATIONNUMBER$ - $HOSTALIAS$ host is $HOSTSTATE$ **” $CONTACTEMAIL$
}

Also do not forget to modify the # ‘notify-by-email’ command definition
because it is the service notification command and if you would like to get email from desired address for services also, then apply the same thing on mentioned command definition (should be in the same file as the host notification command

Hi

Thank you for info, i don’t know why my command line is too short, it’s my original file and i haven’t modified it.