1, Nrpe realize the principle of remote host monitoring
Nrpe is a feature extension of Nagios that can execute plug-ins on remote Linux/unix hosts, providing some local information about the server to the Nagios monitoring platform by installing Nrpe artifacts and Nagios plug-ins on the remote server. For example, CPU load, memory usage, hard disk use, and so on.
2. Configure Nagios Client
(1) Install the Nagios plug-in on the Nagios client host need to install Nrpe and Nagios plug-ins, Nrpe plug-ins can be downloaded from the official Nagios website, from http://www.nagios.org/download/ Addons Download the latest stable version of Nrpe-2.12.tar.gz, and then start the installation and configuration, the basic operation is as follows:
[Root@test2 ~]# tar zxvf nagios-plugins-1.4.9.tar.gz
[Root@test2 ~]# CD nagios-plugins-1.4.9
[Root@test2 nagios-plugins-1.4.9]#./configure
[Root@test2 nagios-plugins-1.4.9]# make && make install
[Root@test2 ~]# chown nagios.nagios/usr/local/nagios/
[Root@test2 ~]# chown-r nagios.nagios/usr/local/nagios/libexec
(2) Installing the Nrpe plug-in on the client is more complex than installing on the server side because the Nrpe is running as a daemon in the client, as follows:
[Root@test2 ~]# yum install-y OpenSSL openssl-devel
[Root@test2 ~]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz/download? Use_mirror=hivelocity&r=&use_mirror=hivelocity
[Root@test2 ~]# tar zxvf nrpe-2.14.tar.gz
[Root@test2 nrpe-2.14]# Useradd Nagios
[Root@test2 nrpe-2.14]#./configure--enable-ssl--with-ssl-lib
[Root@test2 nrpe-2.14]# make all
[Root@test2 nrpe-2.14]# make Install-plugin
[Root@test2 nrpe-2.14]# make Install-daemon
[Root@test2 nrpe-2.14]# make Install-daemon-config
(3) Configure Nrpe
The Nrpe configuration file is/usr/local/nagios/etc/nrpe.cnf.
First find "server_address=127.0.0.1" to change the following address to the IP address of the client host, and then locate the "allowed_hosts=127.0.0.1" line and change it to: allowed_hosts=127.0.0.1 , the Nagios monitor server's address or domain name modify the role of this configuration is to declare legitimate Nrpe service object, no address specified here is unable to obtain service information from the local Nrpe.
"Nagios monitor server's address or domain name" can be an IP address, or it can be a domain name. Can be set according to their own circumstances.
(4) Start the Nrpe daemon
Starting Nrpe is simple, just do the following:
/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg-d
It is recommended that you add this command to the/etc/rc.local file so that you can automatically run the Nrpe daemon on the power-on.
The default port for the Nrpe daemon is 5666, and the following command allows you to detect whether the port is started:
[Root@test2 ~]# Netstat-antl|grep 5666
TCP 0.0.0.0:5666 0.0.0.0:*listen
As you can see, the Nrpe daemon Port 5666 is already started.
(5) Test Nrpe function
First Test on the Nagios client computer, execute the following command:
[Root@test2 ~]#/usr/local/nagios/libexec/check_nrpe-h 192.168.87.135
Check_nrpe:error-could not complete SSL handshake.
If normal, you should receive the following message:
[Root@nagios-client ~]#/usr/local/nagios/libexec/check_nrpe-h 127.0.0.1
NRPE v2.12
The normal return value is the version information of the Nrpe installed on the monitored server, and if you can see this, it means that Nrpe is working properly.
/usr/local/nagios/libexec/check_nrpe-h 127.0.0.1
Check_nrpe:error-could not complete SSL handshake.
This error indicates that the client is not installed OpenSSL cannot complete the SSL handshake
(6) Define the contents of the Monitoring server
To monitor certain information under a remote server, first define the monitored content in the remote server, for example, if you want to monitor the current number of users on a remote server, CPU load, disk utilization, and swap space usage, you need to define the monitoring content in nrpe.conf:
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_sda5]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/sda5
Command[check_zombie_procs]=/usr/local/nagios/libex/check_procs-w 5-c 10-s Z
Command[check_total_procs]=/usr/local/nagios/libexec/check_procs-w 150-C 200
Command[check_swap]=/usr/local/nagios/libexec/check_swap-w 20-c 10
Where the contents of the parentheses after the command are defined variables, the variable names can be specified arbitrarily.
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/soft/tools/
3. Install Nrpe and configure Nagios services on the service side
(1) Install Nrpe plug-in Nrpe installed in the service side is very simple, the operation is as follows:
[Root@test1 ~]# wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz/download? Use_mirror=hivelocity&r=&use_mirror=hivelocity
[Root@test1 ~]# tar zxvf nrpe-2.14.tar.gz
[Root@test1 ~]# CD nrpe-2.14
[Root@test1 nrpe-2.14]# yum install-y OpenSSL openssl-devel
[Root@test1 nrpe-2.14]#./configure--enable-ssl--with-ssl-lib
[Root@test1 nrpe-2.14] #make all && make Install-plugin && make Install-daemon && make Install-dae Mon-config
[Root@test1 nrpe-2.14]# Cp/usr/local/nagios/etc/nrpe.cfg/usr/local/nagios/bin
The Check_nrpe plug-in is installed by default to the/usr/local/nagios/libexec directory through the Make Install-plugin command.
(2) test plug-in and client whether the normal communication on the Nagios server (that is, Nagios monitoring platform) to execute the following instructions:
/USR/LOCAL/NAGIOS/LIBEXEC/CHECK_NRPE-H Client Host Address
For example:
[Root@test1 ~]#/usr/local/nagios/libexec/check_nrpe-h 192.168.87.135
NRPE v2.14
If you can display the output information as above, it indicates that Nrpe can communicate with the client normally.
(3) Define a Check_nrpe monitoring command
Modify the/usr/local/nagios/etc/commands.cfg file and add the following:
Define Command
{
Command_name Check_nrpe
Command_line $USER 1$/check_nrpe-h $HOSTADDRESS $-C $ARG 1$
}
(4) Add remote host monitoring modify/USR/LOCAL/NAGIOS/ETC/OBJECTS/SERVICE.CFG, add the following monitoring content: