Page 2 of 2

Re: How to configure email alert notification?

Posted: Thu Apr 09, 2015 1:21 pm
by lmiltchev
Can you post the command and the contact definitions?

Re: How to configure email alert notification?

Posted: Fri Apr 10, 2015 3:23 am
by lsazzad
Hi lmiltchev,

Thanks for the reply.

1) Fortunately i am receiving mail to my email address when i change $CONTACTMAIL$ to my email address at command.cfg file. But i think its for temporarily. When i need to segregrate contacts then i need to do modify. When i use $CONTACTMAIL$ in command.cfg file i can't receive any email during device state change.



CONTACT:
define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email [email protected] ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

COMMAND:
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** R&R Central Network Monitoring System(NMS) *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" [email protected]
}

# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** R&R Central Network Monitoring System(NMS) *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /usr/bin/mailx -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" [email protected]
}

2) Another thing is that recently i have added proxy email address([email protected]) with my enail address by my exchange server & receiving the service notification. But i need to change this email address(From "root@mydomain" to "myemail-address@mydomain"). Could you help by sharing the path?

3) At root@mydomain email address i am reciving following message in every 10 minutes.

Subject: Cron <smmsp@RR-DE-NMS-1> test -x /etc/init.d/sendmail && /usr/share/sendmail/sendmail cron-msp
Body of Message: /usr/share/sendmail/sendmail: 899: /usr/share/sendmail/sendmail: /usr/sbin/sendmail-msp: not found

Before i have installed SendMail & after that i have installed postfix. Is it happening due to SendMail? Should SendMail removal can do that resloution?

Re: How to configure email alert notification?

Posted: Fri Apr 10, 2015 12:11 pm
by tgriep
1. If you remove $CONTACTMAIL$ from the notify-host-by-email and notify-service-by-email and just put in your email addresses, if is set to only send emails you you and no one else will receive emails at all. I would put back the $CONTACTMAIL$ in that command. If you want to receive notifications for a host or service, you will need to edit those and add the following in your checks.

Code: Select all

contacts                        nagiosadmin
That should enable the nagiosadmin to receive emails.

2. To change your From address in your emails, you will have to configure the email server you are using on the Nagios system. Are you using sendmail or postfix?

3. That looks like your cron process is sending emails and is not related to Nagios. But here is a link that may help you.
http://unix.stackexchange.com/questions ... o-dev-null

Re: How to configure email alert notification?

Posted: Fri Apr 07, 2017 5:21 am
by karthikeyaece
Hi ,

i have configured nagios to send mail alert using "sendmail" option. But i dint receive any mail notification like host down or up etc...But i could able to get test notification.
What i am missing here, please help

Thanks
Karthi

Re: How to configure email alert notification?

Posted: Fri Apr 07, 2017 9:26 am
by tgriep
Take a look in the /var/log/maillog file when the Nagios system generated an email notification and see if there are any errors.
If you see any errors that the says the root email address is rejected, you can change the from address by adding the following option

Code: Select all

-r myemail-address@mydomain
To the end of both of these commands.

Code: Select all

notify-host-by-email
notify-service-by-email
That should fix the sending of emails as root.
If you need help, post the errors from that file so we can view them.