Mail Issues Nagios 4 - Ubuntu

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
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Mail Issues Nagios 4 - Ubuntu

Post 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$
	}
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Mail Issues Nagios 4

Post 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?
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Mail Issues Nagios 4

Post 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
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Mail Issues Nagios 4

Post 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?
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Mail Issues Nagios 4

Post by nathanplatt »

Code: Select all

nagios@nagios:~$ which mail
/usr/bin/mail
As requested
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Mail Issues Nagios 4

Post 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.
nathanplatt
Posts: 267
Joined: Thu May 07, 2015 4:59 am

Re: Mail Issues Nagios 4

Post by nathanplatt »

That worked perfectly, thank you for you help. Please close this case.
Locked