LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Settings for mail notification Nagios. (https://www.linuxquestions.org/questions/linux-networking-3/settings-for-mail-notification-nagios-862774/)

Sturme 02-15-2011 02:40 AM

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

never say never 02-15-2011 12:08 PM

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!
        }


Sturme 02-16-2011 02:49 AM

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

never say never 02-16-2011 07:40 AM

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.

Sturme 02-16-2011 08:25 AM

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


All times are GMT -5. The time now is 10:53 AM.