I am using nagios 3.06 to monitor the servers. When a service is critical, it sends a mail, but when a server is down no mail is sent. Even if all the services go to critical state, no mail is sent.

I have the following configuration:

define command {
    command_name notify-host-by-email
    command_line python /etc/nagios3/send_mail.py "[Nagios] $HOSTNAME$" "******** Nagios ****\n\n Host: $HOSTNAME$\n Description: the server is down"
}

define command{
    command_name notify-service-by-email
    command_line python /etc/nagios3/send_mail.py "[Nagios] $HOSTNAME$: $SERVICEDESC$ ($NOTIFICATIONTYPE$)" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\nDate/Time: $LONGDATETIME$\nAdditional Info:$SERVICEOUTPUT$"
}

The python script is a script to sent a mail. It works if I execute it from the command line, but it doesn't sents an email from nagios.

What I am doing wrong?

UPDATE: The contact data is:

define contact{
    contact_name root
    alias Root
    service_notification_period 24x7
    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 myemail@gmail.com
}

define contactgroup{
    contactgroup_name admins
    alias Nagios Administrators
    members root
}

link|improve this question
feedback

3 Answers

What are your service_notification_options and host_notification_options set to for your contact or contactgroup (if it exists there)? Since you're receiving an email for warning, it sounds like you do not have c set for service_notification_options and do not have d set for host_notification_options

link|improve this answer
updated the information – tzulberti Dec 7 '10 at 21:24
feedback

in your contact {} do you have the following?

host_notification_commands      host-notify-by-email
link|improve this answer
yes, I updated the information... – tzulberti Dec 7 '10 at 21:26
feedback

First check and see that nagios is actually kicking off your script by looking at nagios.log. If it is taking the appropriate action you can try logging the output of your email script by adding 2>&1 >> /tmp/mynagiosemail.log to see if it's throwing an error, either python related or os related.

I noticed that your script is in /etc/nagios3, this is an abnormal place for putting something that nagios will be executing, you may want to move it to /usr/lib/nagios/plugins/ or /usr/lib/nagios3 just to be consistant and then make sure that the nagios user can read and execute it. It doesn't look like there are any apparmor limitations on that but it can't hurt.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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