Nrpe configuration of Nagios (excellent)

Source: Internet
Author: User
Tags pdf manual
Implementation of Nagios: Nagios adopts distributed-centralized management mode. Install the main Nagios program on the Nagios server,
Install the Nagios agent on the monitored host. Monitors the host status through communication between the main Nagios program and the Nagios agent program.
There are two ways to work between the master program and the proxy program. One is the master program --> active --> proxy program; the other is the master program --> passive --> proxy program; as the name suggests, it is divided by one direction to the other side to propose communication requirements.
I. Functions and significance of nrpe:
I have understood the working relationship between the Nagios service-command-plug-in. Therefore, it is clear that the basic Nagios service cannot monitor the status of the remote system, the basic Nagios monitoring service can only be used for local system monitoring and remote host connectivity monitoring. To enable the monitoring server of Nagios to remotely obtain information on the system of the monitored host, for example, the number of processes on the remote system, disk space usage, and running services must be logged on to the remote host system for information, it is necessary to rely on the nrpe core extension plug-in. nrpe, as the intermediate agent, plays a role in accepting requests from the Nagios monitoring server, another man-in-the-middle role that obtains the specified information on the remote host system.

Ii. How nrpe works:
As mentioned above, to monitor the remote system of Nagios, you must first install the native core extension plug-in program in addition to the Nagios-plugins plug-in program on the monitored remote host, the nrpe runs as a daemon on the monitored remote host system. The specified nrpe listening port is opened to listen to all monitoring requests sent by the Nagios monitoring server. In addition, on the Nagios monitoring server, you must install the Nagios-plugins plug-in and the nrpe core extension plug-in. The only difference is that the Nagios monitoring server does not need to run nrpe as a daemon, because it generally does not need to be monitored by others but to monitor others. For the Nagios monitoring server, it only needs to use the nagio-plugins plug-in program and the nrpe extension plug-in program.

3. Install the Nagios-plugins agent on the monitored Host:
1. Add a nagio user
[Root @ kcentos5a ~] # Useradd Nagios

2. Prepare the Nagios-plugins and nrpe source code packages.
[Root @ kcentos5a ~] # Ll
-------------------------------------------------------
Total 2008
-RW ------- 1 Root 928 Oct 3 anaconda-ks.cfg
-RW-r -- 1 Root 22760 Oct 3 :33 install. Log
-RW-r -- 1 Root 2888 Oct 3 :33 install. log. Syslog
-RW-r -- 1 Root 1693979 Sep 30 nagios-plugins-1.4.10.tar.gz
Nagios-plugins plug-in package

-RW-r -- 1 Root 305019 Sep 30 nrpe-2.9.tar.gz
Nrpe Extension function package
-------------------------------------------------------
3. decompress the Nagios-plugins package
[Root @ kcentos5a ~] # Tar-zxvf nagios-plugins-1.4.10.tar.gz

4. Go to the Nagios-plugins plug-in package directory
[Root @ kcentos5a ~] # Cd nagios-plugins-1.4.10

5. Pre-configure the Nagios-plugins installation path
[Root @ kcentos5a nagios-plugins-1.4.10] #./configure -- prefix =/usr/local/Nagios

6. After the pre-configuration is complete, information is fed back and makefile is generated.
-------------------------------------------------------
Config. Status: Creating po/makefile
-- With-Apt-get-command:
-- With-ping6-command:/bin/ping6-n-u-w % d-C % d % s
-- With-ping-command:/bin/ping-n-u-w % d-C % d % s
With-ipv6: Yes
-- With-MYSQL: No
-- With-OpenSSL: Yes
-- With-gnutls: No
-- With-perl:/usr/bin/perl
-- Enable-perl-modules: No
-- With-cgiurl:/Nagios/cgi-bin
-- With-trusted-path:/bin:/sbin:/usr/bin:/usr/sbin
-------------------------------------------------------

7. Compile the Nagios-plugins plug-in program
[Root @ kcentos5a nagios-plugins-1.4.10] # Make

8. Install the Nagios-plugins plug-in program
[Root @ kcentos5a nagios-plugins-1.4.10] # make install

9. Check the Nagios-plugins plug-in installation.
[Root @ kcentos5a nagios-plugins-1.4.10] # ll/usr/local/Nagios/
Total 8
Drwxr-XR-x 2 root Root 4096 Oct 7 0:02 libexec
Drwxr-XR-x 3 Root 4096 Oct 7 0:02 share

10. recursively change the owner of the Nagios main path
[Root @ kcentos5a ~] # Chown-r Nagios. Nagios/usr/local/Nagios/

11. Check attributes of the main path of Nagios
[Root @ kcentos5a ~] # Ll/usr/local/| grep Nagios
Drwxr-XR-x 4 Nagios 4096 Oct 7 Nagios
[Root @ kcentos5a ~] # Ll/usr/local/Nagios/
Total 8
Drwxr-XR-x 2 Nagios 4096 Oct 7 libexec
Drwxr-XR-x 3 Nagios 4096 Oct 7 Share

4. Install the nrpe extension program on the monitored Host:
1. decompress the nrpe compressed package
[Root @ kcentos5a ~] # Tar-zxvf nrpe-2.9.tar.gz

2. Go to the nrpe package directory
[Root @ kcentos5a ~] # Cd nrpe-2.9

3. Pre-configure the nrpe Installer
[Root @ kcentos5a nrpe-2.9] #./configure

4. After the pre-configuration is complete, a prompt message and a makefile are displayed.
-------------------------------------------------------
Configure: Creating./config. Status
Config. Status: Creating makefile
Config. Status: Creating src/makefile
Config. Status: Creating SUBST
Config. Status: Creating include/config. h
* ** Configuration summary for nrpe 2.9 08-13-2007 ***:
General options:
-------------------------
Nrpe port: 5666
Nrpe User: Nagios
Nrpe group: Nagios
Nagios User: Nagios
Nagios group: Nagios
Review the options abve for accuracy. If they look okay,
Type 'make all' to compile the nrpe daemon and client.
Finally, the system prompts you to continue using the "make all" command to compile the nrpe daemon and client programs.
-------------------------------------------------------

5. Compile the nrpe Program
[Root @ kcentos5a nrpe-2.9] # Make all

6. After compilation is successful, a prompt will be reported.
-------------------------------------------------------
* ** Compile finished ***
If the nrpe daemon and client compiled without any errors, you
Can continue with the installation or upgrade process.
Read the PDF documentation (nrpeation) for information on the next
Steps You shoshould take to complete the installation or upgrade.
There is a nrpe.pdf manual in the nrpe package. Next, you can refer to the Manual for subsequent operations.
-------------------------------------------------------
Install the nrpe plug-in, daemon, and template daemon configuration files.
Install the nrpe plugin (for testing), daemon, and sample daemon config file.

7. Install the nrpe plug-in program
[Root @ kcentos5a nrpe-2.9] # make install-plugin

8. Install the nrpe daemon
[Root @ kcentos5a nrpe-2.9] # make install-daemon

9. Install the nrpe Daemon Configuration File
[Root @ kcentos5a nrpe-2.9] # make install-Daemon-config

10. Check the installation of the nrpe Program
[Root @ kcentos5a nrpe-2.9] # ll/usr/local/Nagios/
-------------------------------------------------------
Total 16
Drwxrwxr-x 2 Nagios 4096 Oct 7 Bin
Drwxrwxr-x 2 Nagios 4096 Oct 7 etc
Drwxr-XR-x 2 Nagios 4096 Oct 7 libexec
Drwxr-XR-x 3 Nagios 4096 Oct 7 Share
-------------------------------------------------------

5. Configure and run nrpe on the monitored Host:
1. Configure the main configuration file for nrpe
[Root @ kcentos5a ~] # Vi/usr/local/Nagios/etc/nrpe. cfg
Here are some key settings.
-------------------------------------------------------
Pid_file =/var/run/nrpe. PID
Set the PID file that nrpe runs, which is set by default and does not need to be changed.

Server_port = 5666
This is the system Port occupied by the nrpe daemon.

# Server_address = 0.0.0.0
Server_address = 192.168.1.9 # This is the IP address of the controlled end.
Sets the network interface for the system to listen to nrpe. Generally, a specific IP address is set. If you want multiple NICs, use commas (,) to separate multiple IP addresses. To listen to all network interfaces of the system, you can use "0.0.0.0" to indicate the special addresses of all network interfaces, but you cannot use the wildcard "*".

Nrpe_user = Nagios
Nrpe_group = Nagios
Set the host user of the nrpe.

Allowed_hosts = 192.168.1.12 # This is the IP address of the monitoring server.
Here is the IP address of the host that allows nrpe interaction with the local machine, that is, the address of the Nagios monitoring server. If you want to specify multiple Nagios servers, use a comma ", to separate multiple IP addresses.

Command [check_users] =/usr/local/Nagios/libexec/check_users-W 5-C 10
Command [check_load] =/usr/local/Nagios/libexec/check_load-W 15,10, 5-C 30,25, 20
Command [check_hda1] =/usr/local/Nagios/libexec/check_disk-W 20%-C 10%-P/dev/hda1
Command [check_zombie_procs] =/usr/local/Nagios/libexec/check_procs-W 5-C 10-s Z
Command [check_total_procs] =/usr/local/Nagios/libexec/check_procs-W 150-C 200
The above is the default extension plug-in command of nrpe, which is crucial. When the monitored host runs the nrpe daemon, it also runs the nrpe extension commands defined in the nrpe configuration file. We can see that these extension commands have already specified the command name, plug-in path, and option parameters. The format is as follows:

Command [nrpe command name] = plug-in path/plug-in option 1 parameter 1 option 2 parameter 2...

Note: To specify the service that the monitored host needs to be monitored, you must configure the nrpe command and run it in the nrpe daemon. If no nrpe command is configured, The Nagios monitoring server cannot monitor it.
-------------------------------------------------------
2. Find the execution program run by nrpe
[Root @ kcentos5a ~] # Ll/usr/local/Nagios/bin/nrpe
-Rwxrwxr-x 1 Nagios 93420 Oct 7/usr/local/Nagios/bin/nrpe

3. understand how to use the nrpe execution Program
[Root @ kcentos5a ~] #/Usr/local/Nagios/bin/nrpe-H
-------------------------------------------------------
Usage: nrpe [-N]-C
Running Method: nrpe-C nrpe configuration file path running mode

Options:
Available options

-N = do not use SSL
SSL is generally used instead of SSL.

= Name of config file to use
Specifies the path of the nrpe configuration file. The main configuration file of this nrpe is nrpe. cfg.

= One of the following two operating modes:
Specify the nrpe running mode. There are two available nrpe running modes:

-I = run as a service under inetd or xinetd
Run nrpe using the super daemon inetd or xinetd. To run nrpe in this way, install and configure Xinetd, which is generally not required.

-D = run as a standalone daemon
Run nrpe using an independent daemon.
-------------------------------------------------------
4. Run the nrpe daemon
[Root @ kcentos5a ~] #/Usr/local/Nagios/bin/nrpe-C/usr/local/Nagios/etc/nrpe. cfg-d

5. Check the system log to check the nrpe running status:
[Root @ kcentos5a ~] # Tail/var/log/messages
-------------------------------------------------------
Oct 7 01:45:10 kcentos5a nrpe [21659]: Starting up daemon
It indicates that the nrpe daemon has been successfully started.

Oct 7 01:45:10 kcentos5a nrpe [21659]: listening for connections on port 5666
It indicates that the listening port whose port 5666 is nrpe has been enabled.

Oct 7 01:45:10 kcentos5a nrpe [21659]: allowing connections from: 192.168.1.12
Indicates that access to the specified Nagios monitoring server has been enabled.
-------------------------------------------------------
6. Check the process information of nrpe.
[Root @ kcentos5a ~] # Ps aux | grep nrpe
-------------------------------------------------------
Nagios 21659 0.0 0.3 4396 868? SS/usr/local/Nagios/bin/nrpe-C/usr/local/Nagios/etc/nrpe. cfg-d
-------------------------------------------------------
7. Check the network connection information of nrpe
-------------------------------------------------------
[Root @ kcentos5a ~] # Netstat-nap | grep nrpe
TCP 0 0 192.168.1.9: 5666 0.0.0.0: * Listen 21659/nrpe

UNIX 2 [] dgram 23374 21659/nrpe
-------------------------------------------------------
8. Add the nrpe operation to the system startup script.
[Root @ kcentos5a ~] # Echo "/usr/local/Nagios/bin/nrpe-C/usr/local/Nagios/etc/nrpe. CFG-d ">/etc/rc. d/RC. local

At this point, the tasks of the monitored host have been completed.

6. Install the nrpe core extension on the Nagios Monitoring Server
Compared with the detected host, the nrpe installation on the Nagios monitoring server is relatively simple, and it mainly monitors others rather than others, therefore, it does not need to run nrpe as a daemon, as long as it has the extension plug-in function of nrpe.
1. decompress the nrpe package
[Root @ kcentos5c ~] # Tar-zxvf nrpe-2.9.tar.gz

2. Go to the nrpe package directory
[Root @ kcentos5c ~] # Cd nrpe-2.9

3. Pre-configure the nrpe Installer
[Root @ kcentos5c nrpe-2.9] #./configure

4. Compile the nrpe Program
[Root @ kcentos5c nrpe-2.9] # Make all

5. Install the nrpe Extension Program
[Root @ kcentos5c nrpe-2.9] # make install-plugin
Nagios only needs the extension plug-in function of nrpe, so you can install nrpe on the Nagios monitoring server. The next step is to configure the nrpe extension plug-in command on the Nagios monitoring server so that the Nagios monitoring server can define the nrpe command and thus define the "remote system monitoring service ".

7. Configure the nrpe service on the monitoring host
1. view the usage of the new extension check_nrpe.
[Root @ kcentos5c ~] #/Usr/local/Nagios/libexec/check_nrpe-H | less
-------------------------------------------------------
Usage: check_nrpe-H [-N] [-u] [-p] [-T] [-C]
Usage: check_nrpe-H host name-P nrpe port-C nrpe command name

Options:
Option:

= The address of the host running the nrpe daemon
Host, the remote monitored host name that runs the nrpe daemon, and the host name must be defined in host.

[Port] = the port on which the daemon is running (default = 5666)
Port: The nrpe port on the monitored remote host. The default value is 5666.

[Command] = The Name Of The command that the remote daemon shoshould run
Command. These command names must be run by the nrpe daemon on the monitored host.
-------------------------------------------------------
2. Add the nrpe command in the command. cfg command definition file.
[Root @ kcentos5c ~] # Vi/usr/local/Nagios/etc/commands. cfg
-------------------------------------------------------
# Nrpe command
Add the nrpe FUNCTION command.

Define command (
Command_name nrpe
Command_line $ user1 $/check_nrpe-h $ hostaddress $-C $ arg1 $
}
-------------------------------------------------------
Here are some notes:
(1) The command name defined here is called nrpe.
(2) $ user1 $/check_nrpe obtains the absolute path/usr/local/Nagios/libexec/check_nrpe by referencing resource. cfg.
(3)-H $ hostaddress $ is used to obtain the IP address of the specified monitored host. The $ hostaddress $ variable finds the IP address in the host segment by defining the host name.
(4)-C $ arg1 $ specifies the nrpe command name running by the nrpe daemon on the monitored host.
6. Add the nrpe Remote Monitoring Service on the Nagios monitoring server according to the nrpe command definition:
Add in hosts. cfg
Monitors server hard disk usage by 119
Define host {
Host_name 119
Alias BJ Qmail server
Address IP address of the monitored host
Contact_groups BJ-servers
Check_command nrpe! Check_sda11
Max_check_attempts 5
Icationication_interval 10
Icationication_period 24x7
Notification_options D, U, R
}
Add
Define Service {
Host_name 119
Service_description disk using of Remote System
Check_period 24x7
Max_check_attempts 4
Normal_check_interval 3
Retry_check_interval 2
Contact_groups BJ-servers
Icationication_interval 10
Icationication_period 24x7
Notification_options W, U, C, R
Check_command nrpe! Check_sda11
}
Define Service {
Ensure that the monitored host nrpe. cfg contains check_disk-W 20-C 10-P/dev/sda11 # For example, to monitor the partition of the first hard disk No. 11
Command [check_users] =/usr/local/Nagios/libexec/check_users-W 5-C 10
Command [check_load] =/usr/local/Nagios/libexec/check_load-W 15,10, 5-C 30,25, 20
Command [check_sda11] =/usr/local/Nagios/libexec/check_disk-W 20-C 10-P/dev/sda11
Command [check_zombie_procs] =/usr/local/Nagios/libexec/check_procs-W 5-C 10-s Z
Command [check_total_procs] =/usr/local/Nagios/libexec/check_procs-W 150-C 200

This article is from the chinaunix blog. If you want to view the original text, click:Http://blog.chinaunix.net/u1/40226/showart_1077850.html records: 1. monitored machine Step 1: The monitored machine needs to install nagios-plugins-xxxx.tar.gz and nrpe-xxxx.tar.gz #. /configure -- prefix =/opt/Nagios For details, see the preceding installation step 2: Configure # vi/usr/local/Nagios/etc/nrpe. add a command for checking partitions in CFG (take checking/boot partitions as an example) command [check_boot] =/opt/Nagios/libexec/check_disk-W 20%-C 10%-P/boot2. stepstepstepstep1: Install nrpe step2: added the nrpe command # vi/opt/Nagios/etc/objects/commands. CFG # Add by GMM nrpe command
Define command {
Command_name nrpe
Command_line $ user1 $ check_nrpe-h $ hostaddress $-C $ arg1 $
} Step 3: add monitoring # vi nrpe_test.cfg ################# 10.1.1.10 ################## ##################
Define host {
Use generic-host
Host_name rhel10
Alias rhel10
Address 10.1.1.10
Check_command check-host-alive
Max_check_attempts 2
Contact_groups admins
}
Define Service {
Use generic-service; name of service template to use
Host_name rhel10
Service_description Ping
Check_command check-host-alive
}
Define Service {
Use generic-service; name of service template to use
Host_name rhel10
Service_description check Disk
Check_command nrpe! Check_boot
Check_period 24x7
Max_check_attempts 4
Normal_check_interval 3
Retry_check_interval 2
}

 

 Original article addressHttp://linux.chinaunix.net/bbs/thread-1016249-1-1.html

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.