Nagios not sending mail

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

Nagios not sending mail

Post by ruffsense »

My nagios is not sending notification mail. When i do a custom notification then it send the mail. Can someone please help me out.
I use sendmail.

maillog

Code: Select all

Jan 24 01:19:42 wsgslnagios01 sendmail[10045]: t0O0JgGH010045: from=nagios, size=492, class=0, nrcpts=1, msgid=<201501240019.t0O0JgGH010045@wsgslnagios01.****.lan>, relay=nagios@localhost
Jan 24 01:19:42 wsgslnagios01 sendmail[10046]: t0O0JgEB010046: from=<nagios@wsgslnagios01.*****.lan>, size=741, class=0, nrcpts=1, msgid=<201501240019.t0O0JgGH010045@wsgslnagios01.*****.lan>, proto=ESMTP, daemon=MTA, relay=localhost [127.0.0.1]
Jan 24 01:19:42 wsgslnagios01 sendmail[10045]: t0O0JgGH010045: to=cvaxel@******.nu, ctladdr=nagios (1000/1000), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30492, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (t0O0JgEB010046 Message accepted for delivery)
Jan 24 01:19:42 wsgslnagios01 sendmail[10048]: STARTTLS=client, relay=************.***.lan., version=TLSv1/SSLv3, verify=FAIL, cipher=AES128-SHA, bits=128/128
Jan 24 01:19:42 wsgslnagios01 sendmail[10048]: t0O0JgEB010046: to=<cvaxel@wsg.nu>, ctladdr=<nagios@wsgslnagios01.*****.lan> (1000/1000), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=120741, relay=*********.****.lan. [10.46.150.250], dsn=2.0.0, stat=Sent (<201501240019.t0O0JgGH010045@wsgslnagios01.*****.lan> [InternalId=9230620] Queued mail for delivery
commands.cfg

Code: Select all

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

define command {
	command_name                   	notify-service-by-email
	command_line                   	/usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
	register                       	1
}
contacts.cfg

Code: Select all

define contact {
	contact_name                   	nagiosadmin
	alias                          	Nagios Admin
	contactgroups                  	admins
	host_notifications_enabled     	1
	service_notifications_enabled  	1
	host_notification_period       	24x7
	service_notification_period    	24x7
	host_notification_options      	d,u,r,f,s,n
	service_notification_options   	w,u,c,r,f,s,n
	host_notification_commands     	notify-host-by-email,process-host-perfdata
	service_notification_commands  	notify-service-by-email,process-service-perfdata
	email                          	cvaxel@*****.nu
	use                            	generic-contact
	register                       	1
	}
hosts: ws********.cfg

Code: Select all

define host {
	host_name                      	WS*******
	alias                          	XenApp
	address                        	***.***.***.***
	hostgroups                     	xenapp-servers
	use                            	windows-server
	max_check_attempts             	3
	check_period                   	24x7
	contacts                       	nagiosadmin
	contact_groups                 	admins
	notification_interval          	1
	notification_period            	24x7
	notifications_enabled          	1
	register                       	1
}
I don't insult, I diagnose.
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Nagios not sending mail

Post by abrist »

Well, lets try to send an email from the cli:

Code: Select all

echo "This will go into the body of the mail." | mail -s "Hello world" <your email address>
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked