[SOLVED] Nagios is not generating any email alerts
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have CentOS 5 with nagios installed as instructed by nagios.org , i have an issue related to email alerts , i have added one linux host for testing ping server and getting alerts in the nagios.log file , but not receiving email for that even though sendmail is running fine in the system. Here is the details as below:-
# tail -f /usr/local/nagios/var/nagios.log
1323592672] HOST ALERT: master;DOWN;SOFT;7;CRITICAL - Host Unreachable (192.168.202.137)
[1323592695] Caught SIGTERM, shutting down...
[1323592695] Successfully shutdown... (PID=4577)
[1323592695] Nagios 3.2.3 starting... (PID=5208)
[1323592695] Local time is Sun Dec 11 14:08:15 IST 2011
[1323592695] LOG VERSION: 2.0
[1323592695] Finished daemonizing... (New PID=5209)
[1323592735] HOST ALERT: master;DOWN;SOFT;2;CRITICAL - Host Unreachable (192.168.202.137)
[1323592805] HOST ALERT: master;DOWN;SOFT;3;CRITICAL - Host Unreachable (192.168.202.137)
[1323592875] HOST ALERT: master;UP;SOFT;4;PING OK - Packet loss = 0%, RTA = 0.34 ms
[1323592905] SERVICE ALERT: master;PING;OK;SOFT;4;PING OK - Packet loss = 0%, RTA = 0.56 ms
The ping check test that you are doing need to contain this line:
Code:
notification_options d,r
d = Down
r = Recovery
If this is already the case
Here is a lead to help you understand how Nagios works: (if you follow the Nagios quickstart guide for your installation)
Schema:
1) The file where your ping check is define. It MUST have a live like this "use What_ever_template"
2) In that file is where your template are defined. Here you MUST find the What_ever_template used in your check file. This is where I put my notification_options d,r, you must have as well the "contact_groups eMail-Admin"
3) In that file you MUST find the eMail-Admin group that you specify in your template.cfg file
And here is an example of contact.cfg
Code:
define contact{
name eMail-Admin ; 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,notify-service-by-sms ; send service notifications via email
host_notification_commands notify-host-by-sms ; send host notifications via email
register 0 ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
}
define contact{
contact_name eMail_SMS_JMcCarthy
use eMail-Admin
alias eMail & SMS John McCarthy
email John.McCarthy@Company.com
pager 00353872917972
}
4) In the command.cfg you MUST have the command define in your contact.cfg
(for instance: notify-service-by-email and notify-service-by-sms if you want SMS notification)
command.cfg:
Thanks it is working now but i did some changes below in the default settings
vi contacts.cfg
Quote:
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
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email vijay@localhost
}
# CONTACT GROUPS
#
###############################################################################
###############################################################################
# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin
}
I created one dir and uder it i created one file 192.168.202.137.cfg
Quote:
# Define a host for the local machine
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name master
alias Master Server
address 192.168.202.137
notifications_enabled 1
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options d,r
notification_interval 960
notification_period 24x7
flap_detection_enabled 0
# flap_detection_options o,w,c,u
}
# Define a service to "ping" the local machine
define service{
use local-service ; Name of service template to use
host_name master
service_description PING
check_command check_ping!100.0,20%!500.0,60%
notifications_enabled 1
check_period 24x7
max_check_attempts 4
normal_check_interval 5
retry_check_interval 1
contact_groups admins
notification_options w,u,c,r
notification_interval 960
notification_period 24x7
flap_detection_enabled 0
flap_detection_options o,w,c,u
}
Last edited by mail4vijay; 12-13-2011 at 11:11 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.