Page 2 of 2

Re: Nagios Email Notification Setup

Posted: Fri Oct 07, 2016 1:30 pm
by dwhitfield
I think in the command definition, $CONTACTEMAIL$ -- -r [email protected] should be: -r [email protected] $CONTACTEMAIL$ --

Please let us know if that resolves the issue for you.

Re: Nagios Email Notification Setup

Posted: Fri Oct 07, 2016 3:01 pm
by scheema31
ok perfect, i made the change to use $CONTACTEMAIL$ at the end and now my from address shows up as i configured it, however the to address still shows up funny it shows my address im sending to (like its suppose to) but it also shows the servername "[email protected]; [email protected]"

as for sending email from nagios webpage im seeing some inconsistancy.

- sending a custom host check i get the email right away
- sending a custom service check i dont get the email
- doing a re-schedule check on a host that is down (to force a email alert) does not work, same for the service check
however in the log it shows the command was executed

Code: Select all

10-07-2016 12:51:06] SERVICE NOTIFICATION: Urgent; myvmhost.mycompany.com;Datastore VM-10GDATASTORE-2;CUSTOM (CRITICAL);notify-service-by-email;CRITICAL - /usr/local/nagios/libexec/check_vmfs.sh: line 161: --username: command not found;System Admin;sc
Service Notification[10-07-2016 12:51:06] SERVICE NOTIFICATION: Warning;myvmhost.mycompany.com;Datastore VM-10GDATASTORE-2;CUSTOM (CRITICAL);notify-service-by-email;CRITICAL - /usr/local/nagios/libexec/check_vmfs.sh: line 161: --username: command not found;System Admin;sc
External Command[10-07-2016 12:51:06] EXTERNAL COMMAND: SEND_CUSTOM_SVC_NOTIFICATION;myvmhost.mycompany.com;Datastore VM-10GDATASTORE-2;0;System Admin;sc

Re: Nagios Email Notification Setup

Posted: Mon Oct 10, 2016 1:14 am
by Box293
dwhitfield wrote:I think in the command definition, $CONTACTEMAIL$ -- -r [email protected] should be: -r [email protected] $CONTACTEMAIL$ --

Please let us know if that resolves the issue for you.
scheema31 wrote:- sending a custom service check i dont get the email
Did you also update the notify-service-by-email command

Re: Nagios Email Notification Setup

Posted: Tue Oct 11, 2016 12:39 pm
by scheema31
yes i made the same change to the notify-service-by-email command
i have also noticed that i do get emails from the nagios instance, just seems little lagged and the custom service one doesnt work.
do i need something different in my notify-service-by-email command?

Code: Select all

# 'notify-host-by-email' command definition
define command{
	command_name	notify-host-by-email
	command_line	/usr/bin/printf "%b" "* Nagios Host *\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" -r [email protected] $CONTACTEMAIL$ --
	}

Code: Select all

# 'notify-service-by-email' command definition
define command{
	command_name	notify-service-by-email
	command_line	/usr/bin/printf "%b" "* Nagios Services *\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" --r [email protected] $CONTACTEMAIL$ --
	}
thanks!

Re: Nagios Email Notification Setup

Posted: Tue Oct 11, 2016 12:45 pm
by avandemore
the custom service one doesnt work.
There is something wrong with your service definition, see:
line 161: --username: command not found;System Admin;sc

notify-service-by-email contains an extraneous --
SERVICESTATE$ **" --r [email protected] should be SERVICESTATE$ **" -r [email protected]

Re: Nagios Email Notification Setup

Posted: Wed Oct 26, 2016 3:01 pm
by scheema31
All is working well after the syntax change.

thanks for everyones help! :D

Re: Nagios Email Notification Setup

Posted: Wed Oct 26, 2016 3:29 pm
by dwhitfield
Glad to hear it is resolved. I am going to lock the thread. Please feel free to post again if you have you another issue. Thank you for using the Nagios forums!