Complete nagios configuration documentation (Chapter 3 and Chapter 4)

Source: Internet
Author: User
Chapter 3: run nagios3.1 to verify the correctness of the configuration file. each time you modify your configuration file, you should run a detection program to verify the correctness of the configuration. This is important before running your Nagios program. Otherwise, the Nagios service will be disabled due to configuration errors. Verify your configuration...

 

Chapter 3: running nagios

3.1 verify the correctness of the configuration file

Every time you modify your configuration file, you should run a detection program to verify the correctness of the configuration. This is important before running your Nagios program. Otherwise, the Nagios service will be disabled due to configuration errors.

To verify your configuration, run Nagios with command line parameters? V, like this:

/Usr/local/nagios/bin/nagios? V/usr/local/nagios/etc/nagios. cfg

If you have forgotten some important data or misconfigured data, Nagios will give an alarm or an error message, and the wrong location will be displayed. The error message usually prints the row in the wrong configuration file. In case of an error, Nagios usually returns to the command line status after the source configuration file line is checked out. This makes Nagios not fall into a configuration loop error that needs to be verified due to an error nested. Alarm information can be ignored, because it is not necessary to create an alarm.

Once you have verified your configuration file and modified your error, you can continue, start or restart the Nagios service.

 

3.2 start and stop nagios

Initialization script: the simplest way to start the Nagios daemon is to use the initialization script, as shown in the following code:

/Etc/rc. d/init. d/nagios start

Manually: you can manually start the Nagios Daemon by using command parameters? D, like this:

/Usr/local/nagios/bin/nagios? D/usr/local/nagios/etc/nagios. cfg

Restart Nagios

When you modify the configuration file and want it to take effect, the restart or reload operation is required.

Initialization script: The easiest way to restart the Nagios daemon is to use the initialization script, as shown in the following code:

/Etc/rc. d/init. d/nagios reload

Evaluate start time

/Usr/local/nagios/bin/nagios? S/usr/local/nagios/etc/nagios. cfg

Pre-cache object configuration

Nagios can accelerate the parsing of the configuration file, especially when the template is used in the configuration for inheritance. To reduce the processing time of Nagios parsing configuration files, you can use the functions of Nagios preprocessing and pre-cache configuration files.

When used? When running Nagios with the p command parameter, Nagios reads the configuration file and writes the configuration result to the pre-cache file after processing (the file location is specified by the precached_object_file field in the master configuration file ). The pre-cache configuration file contains the pre-processed information, which makes it easier and faster for Nagios to process the configuration file. Required? P parameter options and? V or? The s command parameters are used together, as shown in the following example. Note that the configuration must have been verified before the pre-cache configuration file is executed. /Usr/local/nag

 

Once a pre-cache object configuration file is created, can it be included when Nagios is started? U command

Save the configuration file instead of the configuration file itself. /Usr/local/nagios/bin/nagios? Ud/usr/

 

 

Chapter 4 Add the monitored end

4.1 install nagios-plugins and nrpe on the monitored side

1. on the monitored host

Add users

Useradd nagios

Set password

Passwd nagios

 

2. install the nagios plugin

Tar? Zxvf nagios? Plugins? * ** .Tar.gz

Cd nagios? Plugins? ***

./Configure

Make

Make install

Chown nagios. nagios/usr/local/nagios

Chown? R nagios. nagios/usr/local/nagios/libexec

 

3. install nrpe ?)

Tar? Zxvf nrpe? * ** .Tar.gz

Cd nrpe? 2.8.1

./Configure

Make all

Make install? Plugin

Make install? Daemon

Make install? Daemon? Config

/Usr/local/nagios/libexec/check_nrpe? H localhost

 

Returns the current NRPE version.

#/Usr/local/nagios/libexec/check_nrpe? H localhost

NRPE v2.8.1

 

Start NRPE on the monitoring and monitored machine:

/Usr/local/nagios/bin/nrpe? C/usr/local/nagios/etc/nrpe. cfg? D

 

Connect to the remote NRPE:

/Usr/local/nagios/libexec/check_nrpe? H

 

That is, it is normal to connect nrpe daemon with check_nrpe locally.

Note: In order to continue working smoothly, you must enable the local firewall 5666 to allow access by external invigilators.

/Usr/local/nagios/libexec/check_nrpe-h

Can we see that the usage is check_nrpe-H monitored host? C. The monitoring command to be executed

Note :? The monitoring command after c must be defined in the nrpe. cfg file. that is, NRPE daemon only runs the command defined in nrpe. cfg.

 

Open remote login under nrpe. cfg:

Vim/usr/local/nagios/nrpe. cfg

Allowed_hosts = 127.0.0.1, 10.1.16.111

Note that the two IP addresses are separated by commas (,).

 

4.2 add the monitored end

 

1. modify the configuration file nagios. cfg

/Usr/local/nagios/etc/nagios. cfg

 

For example, export _file =/usr/local/nagios/etc/objects/commands. cfg

Export _file =/usr/local/nagios/etc/objects/centos2.cfg

Add a new host configuration file centos2.cfg (note the storage path defined)

 

2. create/usr/local/nagios/etc/objects/centos2.cfg.

The content of the new centos2.cfg file can be the same as commands. cfg/localhost. cfg, custom host and service.

 

3. edit the notification recipient group and recipient

 

Templates. cfg/constacts. cfg

This article is from the "My home location" blog

 

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.