Nagios remote host monitoring

Source: Internet
Author: User

In previous articles, I have introduced Nagios installation and plug-in compiling. In practice, it is found that the Nagios service is not powerful in monitoring remote hosts, and the nrpe module must be installed to support it. The following describes how Nagios uses nrpe to monitor remote host survival, disk space, load, process count, and IP connection.

1. Introduction to nrpe principles

Implementation of Nagios: Nagios adopts distributed-centralized management mode.

Install the main Nagios program on the Nagios server and 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.

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.

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.

2. Install the Nagios-plugins agent on the monitored host

1. Add a Nagios user

$useradd nagios

2. Prepare the Nagios-plugins and nrpe source code packages, compile and install them.

$tar -zxvf nagios-plugins-1.4.10.tar.gz 
$cd nagios-plugins-1.4.10
$./configure --prefix=/usr/local/nagios
$make;make install
$chown -R nagios:nagios /usr/local/nagios/
      
3. Install the nrpe service on the monitored host
$tar -zxvf nrpe-2.9.tar.gz
$cd nrpe-2.9
$./configure
$make all
$ make install-plugin;make install-daemon;make install-daemon-config;
           
4. Configure and run nrpe on the monitored host

1. Configure the main configuration file VI/usr/local/Nagios/etc/nrpe. cfg for nrpe.

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. Add the nrpe operation to the system startup script.

$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.

5. 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.

$tar -zxvf nrpe-2.9.tar.gz 
$cd nrpe-2.9
$./configure
$make all
$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 ".

 

Reference: http://linux.chinaunix.net/techdoc/system/2008/07/10/1016249.shtml http://www.2cto.com/ OS /201102/83674.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.