Page 1 of 1

Mail Issues Nagios 4 - Ubuntu

Posted: Tue Jul 21, 2015 4:47 pm
by nathanplatt
Hi Everyone,

Upgrading to version 4 has been an issue, I've managed to install postfix and mailutil on ubuntu, i have managed to run a few test mails but I'm not getting any notifications from the system.

Here are my logs;

Code: Select all

define contact{
        contact_name                    itsupport
        alias                           IT Support
        service_notification_period     workhours
        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]
        }

define contact{
        contact_name                    marketing
        alias                           Marketing Department
        service_notification_period     workhours
        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]
        }

define contact{
        contact_name                    software
        alias                           Software Department
        service_notification_period     workhours
        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]
        }

Code: Select all


# '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: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
	}

# 'notify-service-by-email' command definition
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$
	}

Re: Mail Issues Nagios 4

Posted: Tue Jul 21, 2015 4:50 pm
by jdalrymple
After having just worked through a similar problem on the forums - my first observation is that this other individual had mail at /usr/bin/mail on his Ubuntu box.

Can you `which mail` on your system to double check yours?

Re: Mail Issues Nagios 4

Posted: Tue Jul 21, 2015 5:07 pm
by nathanplatt
Can you define, which mail? I've send test mails with echo and they where received. Can you give me command suggestions to test. I mimic the setup from my Nagios3 box but i did most of my work in the twightlight hours and have since forgotten what i did. The google searches I've done, don't shed a lot of light.

Thanks in advance

Nathan

Re: Mail Issues Nagios 4

Posted: Tue Jul 21, 2015 5:13 pm
by jolson
Try running the command which mail and reporting the result back to this thread. Is the location of your mail binary /usr/bin/mail?

Re: Mail Issues Nagios 4

Posted: Tue Jul 21, 2015 5:16 pm
by nathanplatt

Code: Select all

nagios@nagios:~$ which mail
/usr/bin/mail
As requested

Re: Mail Issues Nagios 4

Posted: Wed Jul 22, 2015 8:55 am
by jdalrymple
There is your problem.

Note that in your command you're trying to call /bin/mail
On your system though the mail command is in /usr/bin/mail

Please change your notify-host-by-email and notify-service-by-email commands accordingly and mail may indeed start flowing.

Re: Mail Issues Nagios 4

Posted: Wed Jul 22, 2015 11:18 am
by nathanplatt
That worked perfectly, thank you for you help. Please close this case.