The previous article describes how to install Nagios Core, an article to share with you how to incorporate a remote Linux server into your monitoring scope.
Part I: Installing Nagios plugins and Nrpe on remote Linux
Step one: Download the setup program for Nagios plugins and Nrep extensions
[Plain]View PlainCopy
- CD Downloads
- wget http://nagios-plugins.org/download/nagios-plugins-2.0.tar.gz
To access http://www.nagios.org/download/addons/, click NRPE, click the Download URL in the pop-up page to download it.
Step Two: Create a user
[Plain]View PlainCopy
- /usr/sbin/useradd Nagios
Step three: Install Nagios Plugins
[Plain]View PlainCopy
- Tar XF nagios-plugins-2.0.tar.gz
- CD nagios-plugins-2.0
- Export LDFLAGS=-LDL
- Sudo-s
./configure--with-nagios-user=nagios--with-nagios-group=nagios--enable-redhat-pthread-workaroundmake && Make install
Chown Nagios.nagios/usr/local/nagios<chown-r nagios.nagios/usr/local/nagios/libexec/
Fourth Step: Install Nrpe
[Plain]View PlainCopy
- Tar XF nrpe-2.15.tar.gz
- CD nrpe-2.15
- ./configure
- Make all
- Make Install-plugins
- Make Install-daemon
- Make Install-daemon-config
- Make install-xinetd
Fifth step: Set Nrpe as Daemon (via as part of XINETD)
- Open the/etc/xinetd.d/nrpe file and add the IP address of the server that is responsible for monitoring to the ONLY_FROM directive. Multiple IP addresses should be separated by a space;
- Edit/usr/local/nagios/etc/nrpe.cfg, after the allowd_hosts instruction, add the IP address of the monitoring server, the address is separated by commas;
- Modify the/etc/services file to add a line at the end of the file:[plain] view plain copy
- Nrpe 5666/tcp # Nrpe
- Start service [plain] view plain copy
- Service xinetd Restart
- Verify that the Nrpe port is currently listening on [plain] view plain copy
- Netstat-at | grep Nrpe
- TCP 0 0 *:nrpe *:* LISTEN
- Confirm that the Nrpe is normal [plain] view plain copy
- /usr/local/nagios/libexec/check_nrpe-h localhost
Sixth Step: Modify/usr/local/nagios/etc/nrpe.cfg
The commands defined in this file determine what the server can monitor, that is, the actual monitoring is performed by the program specified in the command in this file. Like what:
Command[check_users]=/usr/local/nagios/libexec/check_users-w 5-c 10command[check_load]=/usr/local/nagios/libexec /check_load-w 15,10,5-c 30,25,20
Before adding to this file, it is a good idea to actually execute this command at the command line:
/usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/sda1
Part II: Increase the configuration of the remote server on the monitoring server
First step: Download the NRPE extension and install
[Plain]View PlainCopy
- Tar XF nrpe-2.15.tar.gz
- CD nrpe-2.15
- ./configure
- Make all
- Make Install-plugins
Confirm if Nrpe can be linked to a remote server
/usr/local/nagios/libexec/check_nrpe-h [remote server IP]
Step Two: Add HOST and Service configuration for the remote monitoring server
As long as you increase the monitoring of the computer, you need to increase these two parts!
Both configurations can be divided into two files, or they can be placed in a file. I copied the/usr/local/nagios/etc/objects/localhost.cfg here and named it for Remotehost.cfg.
Change the host_name and alias in the host block to the name and alias of the corresponding remote server, and change the address to the IP of the remote server.
The definition of Host_group can be deleted, and the name of the remote server is added to the Host_group block in Localhost.cfg, which is written behind localhost, separated by commas.
In all of the following services definitions, change the host so that it is available.
In/usr/local/nagios/etc/nagios.cfg, add a cfg_file instruction to add the newly created file name to the back.
Step Three: Restart Nagios
[Plain]View PlainCopy
- /etc/init.d/nagios start
Build a monitoring system based on Nagios--monitoring remote Linux servers