LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 12-11-2011, 02:48 AM   #1
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Rep: Reputation: 33
Nagios is not generating any email alerts


Hi,

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

root@monitorserver objects]# pwd
/usr/local/nagios/etc/objects
[root@monitorserver objects]# grep vijay contacts.cfg
email vijay@localhost


When i tested email for user vijay i got email like

# mail -v vijay@localhost

, but when my testing host ping up / down i did not receive any email alert,

Please anyone help on this issue and let me know what else i have to check into nagios for this.

Thanks in Advance.
Vijay
 
Old 12-12-2011, 03:05 AM   #2
angel115
Member
 
Registered: Jul 2005
Location: France / Ireland
Distribution: Debian mainly, and Ubuntu
Posts: 542

Rep: Reputation: 79
Hi mail4vijay,

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:
Code:
1) Pingcheck.cfg-|
                 |-> 2)template.cfg-|
                                    |->3)contact.cfg-|
                                                     |->4)command.cfg
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:
Code:
define command{
        command_name    notify-service-by-email
        command_line    /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: http://nagios/nagios/cgi-bin/status.cgi?host=$HOSTNAME$&style=detail\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n$LONGSERVICEOUTPUT$" | /usr/bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert: $HOSTNAME$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
        }

define command{
        command_name    notify-service-by-sms
        command_line    /usr/local/nagios/libexec/eventhandlers/sendsms $CONTACTPAGER$ "NAGIOS $NOTIFICATIONTYPE$ $DATE$ $TIME$ $HOSTNAME$ Service: $SERVICEOUTPUT$"
        }
I hope I've been precise enough,
if not please let me know.

Best regards,
Angel.
 
Old 12-12-2011, 04:52 AM   #3
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
Thanks for the reply , i will check and come to to LQ if i face any issue.
 
Old 12-13-2011, 11:09 PM   #4
mail4vijay
Member
 
Registered: Oct 2009
Location: Delhi
Distribution: CentOS , RHEL
Posts: 214

Original Poster
Rep: Reputation: 33
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Nagios not sending alerts through email lemay_jeff Linux - Networking 3 09-25-2021 12:04 AM
[SOLVED] nagios alerts help mahmoud Linux - Software 8 01-07-2014 08:41 AM
Nagios - warning and critical alerts to different email address sp149 Linux - Newbie 1 12-18-2009 12:52 PM
Nagios plugin wont send email alerts investmentbnker75 Programming 0 11-18-2008 08:49 AM
Why is my email (Smailer-Daemon) failing to be delivered (specifically Nagios Alerts) mdwillia Linux - Software 1 11-17-2003 08:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration