Nagios send mail when server is down

Posted by tzulberti on Server Fault See other posts from Server Fault or by tzulberti
Published on 2010-12-07T20:11:13Z Indexed on 2011/01/11 16:55 UTC
Read the original article Hit count: 188

Filed under:
|

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 [email protected]
}

define contactgroup{
    contactgroup_name admins
    alias Nagios Administrators
    members root
}

© Server Fault or respective owner

Related posts about email

Related posts about nagios