LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 02-15-2011, 02:40 AM   #1
Sturme
LQ Newbie
 
Registered: Feb 2011
Posts: 12

Rep: Reputation: 1
Settings for mail notification Nagios.


Hi,

I'm currently working with Nagios Core 3.2.2 and I'm trying to set up a mail notification.

My current settings:

Commands
Quote:
# 'host-notify-by-email' command definition
define command{
command_name host-notify-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" | mailx -s "Host $HOSTSTATE$ alert for $HOSTNAME$!" $MAILADDRESS$
}
# 'notify-by-email' command definition
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$" | mailx -s "** $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $MAILADDRESS$
}
Services
Quote:
define service{
name generic-service
active_checks_enabled 1
passive_checks_enabled 1
parallelize_check 1
obsess_over_service 1
check_freshness 0
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
register 0
}

define service{
use generic-service
host_name PC
service_description test
is_volatile 0
check_period 24x7
max_check_attempts 3
normal_check_interval 3
retry_check_interval 1
contact_groups admin
notification_interval 120
notification_period 24x7
notification_options w,u,c,r
check_command notify-by-email
}
Host
Quote:
## Template for mail alerts
define host{
name generic-host
notifications_enabled 1
event_handler_enabled 1
flap_detection_enabled 1
process_perf_data 1
retain_status_information 1
retain_nonstatus_information 1
register 0
}

define host{
use generic-host
host_name PC
alias PC
address 192.168.30.35
check_command check-host-alive
max_check_attempts 10
notification_interval 120
notification_period 24x7
notification_options d,u,r
}
Contacs
Quote:
define contact{
contact_name Nagios
alias Nagiosadmin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r,f,s
host_notification_options d,u,r,f,s
service_notification_commands notify-by-email
host_notification_commands host-notify-by-email
email <mail>
}
I have 2 problems:

I'm getting mail that the PC is OK every 3 minutes.

And I don't know what I should config in Service and host .cfg. Sow that I will get a good description of the problem in the mail that Nagios is sending me.

Cheers
 
Old 02-15-2011, 12:08 PM   #2
never say never
Member
 
Registered: Sep 2009
Location: Indiana, USA
Distribution: SLES, SLED, OpenSuse, CentOS, ubuntu 10.10, OpenBSD, FreeBSD
Posts: 195

Rep: Reputation: 37
Not sure why you are getting the e-mail saying things are OK every 3 minutes, I may just be missing it.

When you define your services, make sure you use names that mean something to you. Here is a portion of my services that checks the mail gateways services, notice how each service_description states the service being watched. This is just a very small portion of my configs, I watch everything.


Code:
define service{
        use                             generic-service         ; Name of service template to use

        host_name                       HOST
        service_description             PING
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           2
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            c,r
        check_command                   check_ping!100.0,20%!500.0,60%
        }

define service{
        use                             generic-service         ; Name of service template to use

        host_name                       HOST
        service_description             SMTP [Pre Maia]
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           30
        notification_period             24x7
        notification_options            c,r
        check_command                   check_smtp!25
        }

define service{
        use                             generic-service         ; Name of service template to use

        host_name                       HOST
        service_description             SMTP [Maia]
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           60
        notification_period             24x7
        notification_options            c,r
        check_command                   check_smtp!1024
        }

define service{
        use                             generic-service         ; Name of service template to use

        host_name                       HOST
        service_description             SMTP [Post Maia]
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           60
        notification_period             24x7
        notification_options            c,r
        check_command                   check_smtp!1025
        }
define service{
        use                             generic-service         ; Name of service template to use

       host_name                        HOST
        service_description             MailQ
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           60
        notification_period             24x7
        notification_options            w,u,c,r
        check_command                   check_mailq!10,100!100,1000
#        }

define service{
        use                             generic-service         ; Name of service template to use

        host_name                       HOST
        service_description             SMTP [SQLGrey]
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            1
        contact_groups                  admins
        notification_interval           60
        notification_period             24x7
        notification_options            c,r
        check_command                   check_tcp!2501!
        }
 
Old 02-16-2011, 02:49 AM   #3
Sturme
LQ Newbie
 
Registered: Feb 2011
Posts: 12

Original Poster
Rep: Reputation: 1
Hi,

I'v solved the problem of the mail comming in every 3 minutes. normal_check_interval 3 in combination with the service was the problem.

Now the second problem.

The services that you show, are they the default services of Nagios? Or did you add them, if this is the case were did you add them?

I'm running Check_mk over nagios. My services are defined in the config file of check_mk. So if I add a host it will automatic add the services that he recognized. But I don't know how I add those in the service.cfg.

Cheers

Last edited by Sturme; 02-16-2011 at 05:16 AM.
 
Old 02-16-2011, 07:40 AM   #4
never say never
Member
 
Registered: Sep 2009
Location: Indiana, USA
Distribution: SLES, SLED, OpenSuse, CentOS, ubuntu 10.10, OpenBSD, FreeBSD
Posts: 195

Rep: Reputation: 37
Some are Nagios Plugins (add-ons) some come with Nagios. I added all these checks by hand to the Nagios Config (over 400 so far). I am not familiar with Check_mk, so I afraid I can't help you figure out how to get it to report more relevant information.
 
Old 02-16-2011, 08:25 AM   #5
Sturme
LQ Newbie
 
Registered: Feb 2011
Posts: 12

Original Poster
Rep: Reputation: 1
Oke, thx for your support.

Anyone how reads this and knows the solutions to this problem, or has any understanding of Check_MK please respones.

Cheers
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] NAGIOS mail notification by alert type sem007 Linux - Software 4 06-12-2010 02:52 AM
E-mail notification with Nagios Hiroyatamoto Linux - Newbie 7 06-30-2009 11:18 AM
Nagios E-mail notification Hiroyatamoto Linux - General 5 07-02-2008 03:55 AM
Nagios E-mail notification setup Hiroyatamoto Linux - Newbie 3 07-01-2008 04:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:52 AM.

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