I have configured Nagios 3.4.4 on CentOS 6.3 Final. I have also configured Postfix with SMTP email server. I have verified from console that I am able to send email notifications and recieved them on designated address.

Nagios is configured to send notify-host-by-email and notify-service-by-email. I can see from Nagios logs that service notification alerts and customer notification being sent from Nagios. But nothing is seen on /vag/log/maillog. There are no errors either.

I even fired 'command_line' from below commands from console and they are able to send emails to address mentioned.


# '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" | sudo /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" | sudo /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$


define contact{
    contact_name manish
    service_notification_period 24x7
    host_notification_period 24x7
    service_notification_options w,u,c,r,f
    host_notification_options d,u,r,f
    service_notification_commands notify-service-by-email
    host_notification_commands notify-host-by-email
    email manish@xxx.com

define contactgroup {
    contactgroup_name   email
    alias Email Group
    members manish

Nagios Groups

cat /etc/group |grep nagios
  • Similar configuration is present on Ubuntu and it works without different modification to Nagios or Postfix. – Manish Devraj Mar 18 '13 at 6:50
  • 1
    I don't think you need sudo for /bin/mail. And if you use it it should be configured not to ask for password. – Laurentiu Roescu Mar 18 '13 at 7:10
  • Yes sudo is configured to NOT ask any passwords, so I think we are good there. – Manish Devraj Mar 18 '13 at 7:16
  • You should not be using sudo to run mail, though. – Keith Mar 25 '13 at 20:12

You need to configure contacts or contact_groups in the host/service definition. I normally create a template host and service and then override using inheritance.

http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#host http://nagios.sourceforge.net/docs/3_0/objectdefinitions.html#service http://nagios.sourceforge.net/docs/3_0/objectinheritance.html

  • I do have service created for notification that can send out emails as below, but not sure what it is which is blocking emails. contact_groups emails notification_options w,u,c,r notification_interval 30 notification_period 24x7 – Manish Devraj Mar 18 '13 at 7:10

in contacts.cfg file ,

define contact{

    contact_name                    nagiosadmin             ; Short name of user
    use                             generic-contact         ; Inherit default values
    alias                           Nagios Admin            ; Full name of user
    email                           alerts@domainname.com   }

In nagios.cfg




You can check the url : http://www.thegeekstuff.com/2009/06/4-steps-to-define-nagios-contacts-with-email-and-pager-notification/

  • Thank you, I am using contactgroup as 'emails' which I have also defined in 'Host' and 'Service' I would like to have notification for. I think Nagios went all well triggering notification, but nothing seems to trigger Postfix to get that request and process. Also there is no hit in logs that can show any detailed inforamtion. – Manish Devraj Mar 18 '13 at 12:40

All configurations were correct and no errors were found on either Nagios or Postfix side. It turn out that Nagios was unable to trigger 'mail' command to actually send email notification. I change behavior of command to run a .php to draft a HTML email template and then .php to send out email using 'mail' command. This approach worked for me for above mentioned scenario. Please use http://exchange.nagios.org/directory/Addons/Notifications/Send-HTML-Alert-Email-v2/details guide in case anyone struggiling with similar problem.

  • I believe you will need to install the mailx package to be able to use the mail command on CentOS – Epaphus Mar 19 '13 at 13:20
  • Agreed, it was installed when I reported this problem. – Manish Devraj Mar 20 '13 at 5:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.