Operating System - HP-UX
1831614 Members
2144 Online
110027 Solutions
New Discussion

Nagios not sending alerts

 
Allanm
Super Advisor

Nagios not sending alerts

Nagios is sparingly sending alerts, not sure where the problem is, here is what I have done -

1) created generic contact template and contact (in contacts.cfg) called nagios which is also a local user on the box.

define contact{
name generic-contact ; The name of this contact template
service_notification_period 24x7 ; service notifications can be sent anytime
host_notification_period 24x7 ; host notifications can be sent anytime
service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
service_notification_commands notify-service-by-email ; send service notifications via email
host_notification_commands notify-host-by-email ; send host notifications via email
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}

define contact{
contact_name nagios ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
service_notification_period 24x7
host_notification_period 24x7
service_notification_options u,c
host_notification_options n
service_notification_commands notify-by-email
host_notification_commands notify-host-by-email
email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}

2) within contacts.cfg made it part of admin group -

define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios
}

3) In commands.cfg, created a command to send an alert thru email -

define command{
command_name notify-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$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}

4) In services.cfg added admins group for notification for each of the service defined -

contact_groups admins

5) added a couple of email ids in /etc/aliases -

nagios tom@xxx.com, harry@xxx.com

6) ran newaliases and nagios process using -v and -d switches and it ran just fine.

Sending alert from the commandline also works.Even I got a few email alerts but not consistently.Location of mail is same as defined above in commands,cfg.

Please help!

Thanks,
Allan
2 REPLIES 2
Allanm
Super Advisor

Re: Nagios not sending alerts

Please help!!

Re: Nagios not sending alerts

Hello Allan,
You can add:
define contact{
contact_name tom
...
email tom@xxx.com
}

define contact{
contact_name harry
...
email harry@xxx.com
}

define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagios, tom, harry
}