Nagios NRPE learning experience

Source: Internet
Author: User

Recently, I used Nagios to monitor Several Linux servers. After searching and learning, I successfully achieved this goal. The following describes the installation process and precautions.


First, you need to clearly know how Nagios monitors LINUX servers. They communicate with each other through NRPE addon. NRPE addon consists of nrpe_check and nrpe_daemon. On the nagios server, nrpe_check connects to nrpe_daemon through ssl. By remotely calling the commands defined on nrpe plugin on the linux server, you can obtain various information about the remote server.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/054IVA5-0.png "title =" 1.PNG" alt = "1320020.8.png"/>


Therefore, Nrpe addon must be installed on the Nagios server, while nrpe addon and nrpe plugin must be installed on the remote server.


My nagios server and remote server are both Debian


The following is the installation of the remote client server:


1. The first step is to pre-install related programs

Sudo apt-get install make gcc g ++

Sudo apt-get install libssl-dev

Sudo apt-get install snmpd

Sudo apt-get install snmp scli tkmib

Sudo useradd-p nagios * PASSWORD *


2. Then you can download the latest nagios plugin file and decompress it.


Cd/downloads

Sudo wget transform (** = latest version)

Sudo tar-xzvf nagios-plugins-1.4. ** .tar.gz

Cd nagios-plugins-1.4.13


Detect library files, test, install


Sudo./configure

Sudo make

Sudo make install


The default installation path is/local/usr/nagios. You can also manually confirm the first step./confgure-prefix =/usr/local/nagios

After installation, the access permission is root. We need to change it to nagios.

Sudo chown-R nagios: nagios/usr/local/nagios/

Finally, we need to install xineted and run nrpe as one of its services.

Sudo apt-get install xinetd


3. Install nagios addon on the client


Download and decompress

Cd/usr/src

Sudo wget http://waix.dl.sourceforge.net/sourceforge/nagios/nrpe-2.00000000.tar.gz (** = latest version)

Sudo tar-xzvf nrpe-2. ** .tar.gz

Cd nrpe-2.12


Install

It is worth mentioning that the first step is sudo./configure. I found that files in versions 2.14 and 2.15 cannot be parsed, And the ssl library cannot be found. The solution is as follows:

# Dpkg-L libssl-dev: it will show that my libssl. so is located in/usr/lib/x86_64_linux_gnu)

#./Confiugre -- with-ssl =/usr/bin/openssl -- with-ssl-lib =/usr/lib/x86_64_linux_gnu


For lower versions such as 2.12, run the following command:


Sudo./configure

Sudo make all

Sudo make install-plugin

Sudo make install-daemon

Sudp make install-daemon-config

Sudo make install-xinetd


So far, the installation is complete. The next step is to modify the configuration file.


4. Modify the client's nrpe File

Because we run nrpe through xinetd, the authorized nagios server is in/etc/xinetd. d/nrpe configuration. If xinetd is not installed, the port and running server are in/usr/local/nagios/etc/nrpe. configuration in cfg


Sudo vim/etc/xinetd. d/nrpe

And add to only_from = your Nagios server IP


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/054IU135-1.png "title =" 2.PNG" alt = "133749411.png"/>


Remember to add Port 5666 to services

Sudo echo "nrpe 5666/tcp # NRPE">/etc/services (MUST run as ROOT ).


5 Finally, We have to configure the/usr/local/nagios/etc/nrpe. cfg file. As mentioned above, the port number and server do not need to be configured here, but the commands called by nrpe daemon need to be defined here.


These commands can be executed manually to check whether they work.

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/054IR547-2.png "title =" 3.PNG" alt = "134422345.png"/>


Restart the xinetd service.

Sudo/etc/init. d/xinetd restart


Test whether nrpe runs independently or the xineted-based service.

Sudo netstat-l | grep nrpe

Ps aux | grep nrpe

Netstat-nap | grep nrpe

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/054IT5B-3.png "title =" 4.PNG" alt = "134844254.png"/>


The installation of the Linux client is basically complete.


6. daemon is not required on the Nagios host, so you can install the plug-in and run Step 1 again.


Sudo wget http://waix.dl.sourceforge.net/sourceforge/nagios/nrpe-2.00000000.tar.gz (** = latest version)

Sudo tar-xzvf nrpe-2. ** .tar.gz

Cd nrpe-2.12

Sudo./configure

Sudo make all

Sudo make install-plugin


Next, configure nrpe.

First, let's look at the nrpe syntax.

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

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/054IU412-4.png "title =" 5.PNG" alt = "141713213.png"/>

After reading the syntax, We can configure it in the corresponding command. cfg.

For example, vim/etc/nagios3/command. cfg

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/054IWb2-5.png "title =" 6.PNG" alt = "143850201.png"/>


$ USER1 $ is the path defined in/etc/nagios3/resources. cfg.

It is equivalent to calling/usr/local/nagios/libexec/check_nrpe.

-H is the remote server currently directed

-C is the command on the remote server.

$ ARG1 $ is the command name

After definition, you can configure services in the corresponding server. cfg.


For example, sudo vim/etc/nagios3/objects/au_servers.cfg


650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/054IQW2-6.png "title =" 8.PNG" alt = "1451020.2.png"/>


Check_nrpe! Check_swap

Check_nrpe is defined in nagios server/etc/nagios3/command. cfg ,! Indicates that the daemon program is remotely called, and check_swap is defined in step 1 on the remote server/usr/local/nagios/bin/nrpe.



Another example is:

650) this. width = 650; "src =" http://www.bkjia.com/uploads/allimg/131228/054IT922-7.png "title =" 7.PNG" alt = "144542361.png"/>

This command remotely calls the CheckMem defined in the window client (nsclient ++) to view the physical memory.

The syntax is defined as follows:

Http://www.nsclient.org/nscp/wiki/CheckSystem/checkMem



To be Continued...

This article from the "Mapo tofu" blog, please be sure to keep this source http://beanxyz.blog.51cto.com/5570417/1297683

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.