Not sending emails

I just configured my second nagios server (after 6 months without touching it)… Anyway I have it configured properly to monitor things but I am not getting any emails from nagios.

I can send email from the command line using mail -s “TesT” [email protected] and I check which mail for the location and changed it in commands.cfg, but for some reason I cannot seem to figure out, it is not sending alerts.

thanks

NF

Hi Niles

Pls post your mail notify commands.
Pls confirm you have set the email address in the appropriate contact(s)
Check nagios & mail log for errors

/S

From contacts.cfg :

define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email [email protected]
host_notification_period 24x7
service_notification_period 24x7
host_notification_options d,u,r,n
service_notification_options w,u,c,r,n
host_notification_commands notify-host-by-email
service_notification_commands notify-service-by-email

email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

    }

define contactgroup{
contactgroup_name nagiosadmin
alias Nagios Administrators
members nagiosadmin
}

FROM COMMANDS.CFG:

‘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" | /usr/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$" | /usr/bin/mail -s " $NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **” $CONTACTEMAIL$
}

No errors in nagios.log

Hi

Everything appears to be in order at first. Are you seeing notification attempts in the log? It should be an entry like

timestamp] SERVICE NOTIFICATION: contact;hostname;service;service-state;notify-command;additional-info

like

[1234567890] SERVICE NOTIFICATION: nagiosadmin;SOMEHOST;PING;WARNING;notify-service-by-email;WARNING - 10.38.6.254: rta 158.845ms, lost 20%

Just wondered if the servicechecks are actually firing the email in the first place…

there are not service notifications in the nagios.log file.

I feel that maybe the notification is not being called then for some reason. Maybe we should look at the service definition for something you know has gone down and not notified.

define host{
name generic-host ; The name of this host template
notifications_enabled 1 ; Host notifications are enabled
check_interval 5
event_handler_enabled 1 ; Host event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
max_check_attempts 10
notification_interval 120
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
notification_period 24x7 ; Send host notifications at any time
contact_groups nagiosadmin
register 1 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
}

define service{
name generic-service ; The ‘name’ of this service template
active_checks_enabled 1 ; Active service checks are enabled
passive_checks_enabled 1 ; Passive service checks are enabled/accepted
parallelize_check 1 ; Active service checks should be parallelized (disabling this can lead to major performance problems)
obsess_over_service 1 ; We should obsess over this service (if necessary)
check_freshness 0 ; Default is to NOT check service 'freshness’
notifications_enabled 1 ; Service notifications are enabled
event_handler_enabled 1 ; Service event handler is enabled
flap_detection_enabled 1 ; Flap detection is enabled
failure_prediction_enabled 1 ; Failure prediction is enabled
process_perf_data 1 ; Process performance data
retain_status_information 1 ; Retain status information across program restarts
retain_nonstatus_information 1 ; Retain non-status information across program restarts
is_volatile 0 ; The service is not volatile
check_period 24x7 ; The service can be checked at any time of the day
max_check_attempts 3 ; Re-check the service up to 3 times in order to determine its final (hard) state
normal_check_interval 10 ; Check the service every 10 minutes under normal conditions
retry_check_interval 2 ; Re-check the service every two minutes until a hard state can be determined
contact_groups nagiosadmin ; Notifications get sent out to everyone in the ‘admins’ group
notification_options w,u,c,r ; Send notifications about warning, unknown, critical, and recovery events
notification_interval 60 ; Re-notify about service problems every hour
notification_period 24x7 ; Notifications can be sent out at any time
register 1 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
}

I have tried using resgister 0 or 1 and didnt make a difference. I wish I had access to my old nagios server.

I can see you have registered your templates. I would really recommend you to read the documentation and see what templates are used for and what realy host/service definitions are for. Maybe somewhere in the definition you have settings that overlap each other and that’s why you don’t get emails.
You have also enabled flap detection, which could also lead to not sending notifications if you’re services/host are considered flapping…

Really I would strongly suggest you to read documentation and turn off the things you don’t use

actually, I fixed it a little while ago. didnt have the time to respond. I found some of my config files from my nagios server from months ago, and changed the service settings and BOING, emails.

I just re-customized the emails so that the nagios server can open tickets with out connectwise system.

NF