Loop and progressive Nagios --- operation (2) Configure Nagios

Source: Internet
Author: User

1. Introduction to nagios Default Configuration File

Read more: cyclic and progressive Nagios --- operation (1) install the Nagios Monitoring System

After nagios is installed, the default configuration file is in the/usr/local/nagios/etc directory. The following table lists the meanings of each file or directory:

 

2. Relationship between configuration files
Several definitions involved in nagios configuration include host, Host group, service, service group, contact, Contact Group, monitoring time, and monitoring command, configuration files of nagios are interrelated and referenced.

To successfully configure a nagios monitoring system, you must understand the dependency and dependency between each configuration file. The most important four aspects are as follows:

1. Define the hosts, host groups, services, and service groups to be monitored.

Second, define the command to implement this monitoring,

Third: Define the monitoring time period,

4. Define the contacts and contact groups to be notified when a problem occurs on the host or service.
 

3. Start configuring nagios
To better illustrate the problem and facilitate maintenance, we recommend that you create an independent configuration file for each nagios definition object:

Create the hosts. cfg file to define the host and Host group
Create the services. cfg file to define the service
Use the default contacts. cfg file to define contacts and contact groups.
Use the default commands. cfg file to define commands
Use the default timeperiods. cfg to define the monitoring period
Use the default templates. cfg file as the resource reference file
 

1. templates. cfg file
Nagios is mainly used to monitor host resources and services. It is called an object in nagios configuration. In order not to repeatedly define some monitoring objects, Nagios introduces a template configuration file, define common attributes as templates for multiple references. This is the role of templates. cfg.

The following describes in detail the meaning of each parameter in the templates. cfg file:

Define contact {
Name generic-contact # contact name,
Service_icationication_period 24x7 # The period during which notifications are sent when a service exception occurs. The period "7x24" is defined in the timeperiods. cfg file.
Host_icationication_period 24x7 # The period during which notifications are sent when an exception occurs on the host. The period "7x24" is defined in the timeperiods. cfg file.
Service_icationication_options w, u, c, r # defines the situation where notifications can be issued ". <SPAN style = "COLOR: # ff0000"> w (warn) indicates the warning state, u (unknown) indicates the unknown state, c (criticle) indicates the emergency state, r (recover, indicates the recovery status. </SPAN> that is, a notification is sent to the user when the service has a warning status, unknown status, emergency status, and recovery status.
Host_icationication_options d, u, r # defines the status in which the host needs to send a notification to the user. <SPAN style = "COLOR: # ff0000"> d indicates that the host is down, indicating that the host is down, u is unreachable, indicating that the State cannot be reached, r is recovery, indicating that the State is restored. </SPAN>
Service_icationication_commands notify-service-by-email # When a service fault occurs, you can send notifications by email or text message. Here, you can send notifications by email, "policy-service-by-email" is in commands. in the cfg file.
Host_icationication_commands notify-host-by-email # When the host fails, the notification can be sent by email or SMS. Here, the notification is sent by email, "policy-host-by-email" is in commands. in the cfg file.
Register 0
}
 
Define host {
Name generic-host # host name. The host name here does not directly correspond to the host name of the real machine, but to the host name set in the host configuration file.
Notifications_enabled 1
Event_handler_enabled 1
Flap_detection_enabled 1
Failure_prediction_enabled 1
Process_perf_data 1
Retain_status_information 1
Retain_nonstatus_information 1
Icationication_period 24x7 # specify the period of time when a notification can be sent to the user.
Register 0
}
Define host {
Name generic-switch; The name of this host template
Use generic-host; Inherit default values from the generic-host template <SPAN style = "COLOR: # ff0000"> ---- note that the template defined above is referenced here </SPAN>
Check_period 24x7; By default, switches are monitored round the clock
Check_interval 5; Switches are checked every 5 minutes
Retry_interval 1; Schedule host check retries at 1 minute intervals
Max_check_attempts 10; Check each switch 10 times (max)
Check_command check-host-alive; Default command to check if routers are "alive"
Icationication_period 24x7; Send notifications at any time
Icationication_interval 30; Resend notiications every 30 minutes
Notification_options d, r; Only send notifications for specific host states
Contact_groups admins; Notifications get sent to the admins by default
Register 0; dont register this-ITS JUST A TEMPLATE
}

Define service {
Name generic-service # define a service name
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
Failure_prediction_enabled 1
Process_perf_data 1
Retain_status_information 1
Retain_nonstatus_information 1
Is_volatile 0
Check_period 24x7 # Here check_period tells nagios to check the service period.
Max_check_attempts 3 # maximum number of nagios service checks.
Normal_check_interval 10 # This option is used to set the service check interval, that is, the time between the nagios check and the next check, which is 10 minutes.
Retry_check_interval 2 # retry check interval, in minutes.
Contact_groups admins # specify the Contact Group, as shown in the preceding figure.
Notification_options w, u, c, r # defines the situation where notifications can be issued ". <SPAN style = "COLOR: # ff0000"> w (warn) indicates the warning state, u (unknown) indicates the unknown state, c (criticle) indicates the emergency state, r (recover, indicates the recovery status. </SPAN> notification is sent to the user after the service has a warning status, unknown status, emergency status, and recovery.
Icationication_interval 60 # the fault has not been resolved after the service exception occurs. The time when nagios sends a notification to the user again. The Unit is minute. If you think that only one notification is required for all events, you can set the option here to 0.
Icationication_period 24x7 # specify the period of time when a notification can be sent to the user.
Register 0
}

Nagios details: click here
Nagios: click here

Configure Apsara stack alarms using Nagios

Using Nagios with Apsara for SMS alert Installation

Free SMS alert configuration for Nagios Feixin Linux

How to monitor Linux Hosts and send emails to alarms through Nagios

  • 1
  • 2
  • 3
  • Next Page

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.