Nagios uses Nrpe to monitor Linux hosts

Source: Internet
Author: User
Tags disk usage

First, Introduction

1, Nrpe Introduction

Nrpe is a feature extension of Nagios that executes plug-ins on remote Linux/unix hosts. By installing the Nrpe plugin and the Nagios plug-in on a remote server, you provide the server's local conditions to the Nagios monitoring platform, such as CPU load, memory usage, disk usage, and so on. Here the Nagios Monitor is called the Nagios server side, and the host that is monitored remotely is called the Nagios client.

Nagios monitors remote hosts in a variety of ways, including SNMP,NRPE,SSH,NCSA. Here's how it monitors remote Linux hosts through Nrpe.

NRPE (Nagios Remote Plugin Executor) is a daemon for running monitoring commands on a remote server, which allows the Nagios monitoring side to trigger the detection command on the remote host based on the installation and return the results to the monitoring side. And the execution of the cost is much lower than the SSH-based detection method, and the detection process does not require the remote host system account information, and its security is higher than the SSH detection mode.

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/4A/C3/wKioL1Qm3NLBZZSnAAHCItyFxXI201.jpg "title=" 2.png " alt= "Wkiol1qm3nlbzzsnaahcityfxxi201.jpg"/>


2. Working principle of Nrpe

Nrpe has two components

Check_nrpe plug-in: On the monitoring host

Nrpe Daemon: Run on a remote host, usually a monitored end agent

Note: Nrpe daemon need nagios-plugins plug-in support, otherwise daemon can not do any monitoring

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/4A/C3/wKioL1Qm2krywnxLAACf2VJUtQI655.jpg "title=" 1.jpg " alt= "Wkiol1qm2krywnxlaacf2vjutqi655.jpg"/>

A detailed introduction to how Nrpe works

When Nagios needs to monitor the service or resource conditions of a remote Linux host:

First: Nagios runs the Check_nrpe plugin and tells it what to check;

Second: Check_nrpe plug-in will connect to the remote Nrpe daemon, the way is SSL;

Then: NRPE Daemon will run the appropriate Nagios plugin to perform the check;

Finally: NRPE Daemon Returns the results of the check to the Check_nrpe plugin, which the plugin submits to nagios for processing.


Second, the monitored end installs the Nagios-plugins plug-in and the Nrpe

1. Add Nagios Users

[Email protected] ~]# useradd-s/sbin/nologin Nagios

2, install Nagios-plugins, because Nrpe relies on this plugin

[[email protected] ~]# yum-y install gcc gcc-c++ make OpenSSL openssl-devel[[email protected] ~]# tar XF nagios-plugins-2 .0.3.tar.gz [[email protected] ~]# CD Nagios-plugins-2.0.3[[email protected] nagios-plugins-2.0.3]#./configure-- With-nagios-user=nagios--with-nagios-group=nagios[[email protected] nagios-plugins-2.0.3]# make && make install# Note: How to monitor MySQL needs to add--with-mysql

3, Installation Nrpe

[Email protected] ~]# tar xf nrpe-2.15.tar.gz [[email protected] ~]# CD Nrpe-2.15[[email protected] nrpe-2.15]#./configu Re--with-nrpe-user=nagios >--with-nrpe-group=nagios >--with-nagios-user=nagios >--with-nagios-group= Nagios >--enable-command-args >--enable-ssl[[email protected] nrpe-2.15]# make All[[email protected] nrpe-2.15]# Make Install-plugin[[email protected] nrpe-2.15]# make Install-daemon[[email protected] nrpe-2.15]# make Install-daemon-config

4, Configuration Nrpe

[Email protected] ~]# grep-v ' ^# '/usr/local/nagios/etc/nrpe.cfg |sed '/^$/d ' log_facility=daemonpid_file=/var/run/ nrpe.pidserver_port=5666 #监听的端口nrpe_user =nagiosnrpe_group=nagiosallowed_hosts=192.168.0.105 #允许的地址通常是Nagios服 Server End dont_blame_nrpe=0allow_bash_command_substitution=0debug=0command_timeout=60connection_timeout=300command[ 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,20command[check_hda1]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-p/dev/hda1command[ Check_zombie_procs]=/usr/local/nagios/libexec/check_procs-w 5-c 10-s zcommand[check_total_procs]=/usr/local/ Nagios/libexec/check_procs-w 150-C 200


5, start Nrpe

#以守护进程的方式启动 [[Email protected] ~]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc /nrpe.cfg -d[[email protected] ~]# netstat -tulpn | grep nrpetcp         0      0 0.0.0.0:5666                 0.0.0.0:*                    listen       22597/nrpe          tcp         0      0 :::5666                       :::*                           listen      22597/nrpe 


There are two ways to manage Nrpe services, Nrpe has two modes of operation:

-I # Run as a service under inetd or xinetd-d # Run as a standalone daemon


You can write a startup script for Nrpe that allows Nrpe to run in standard alone mode:

[[email protected] ~]# cat /etc/init.d/nrped #!/bin/bash# chkconfig: 2345  88 12# description: nrpe daemonnrpe=/usr/local/nagios/bin/nrpenrpeconf=/usr/local/ nagios/etc/nrpe.cfgcase  "$"  instart) echo -n  "Starting nrpe daemon ..." $NRPE  -c  $NRPECONF  -decho  " done.";; Stop) echo -n  "Stopping nrpe daemon ..." pkill -u nagios nrpeecho  "  Done. ";; Restart) $0 stopsleep 2$0 start;; *) echo  "Usage: $0 start|stop|restart";; esacexit 0[[email protected] ~]# chmod +x /etc/init.d/nrped [[email  protected] ~]# chkconfig --add nrped[[email protected] ~]# chkconfig  Nrped on[[email protected] ~]# service nrped startstarting nrpe daemon ...  done. [[email protected] ~]# netstat -tnlpactive internet connections  (only servers) proto recv-q send-q local address                foreign address              State        pid/program name   tcp        0       0 0.0.0.0:22                   0.0.0.0:*                    LISTEN       1031/sshd           tcp         0      0 127.0.0.1:25                 0.0.0.0:*                    listen      1108/master          tcp        0       0 0.0.0.0:5666                 0.0.0.0:*                    listen      22597/ nrpe          tcp         0      0 :::22                        :::*                          listen       1031/sshd           tcp         0      0 ::1:25                        :::*                          LISTEN      1108/master          tcp        0       0 :::5666                      :::*                          listen       22597/nrpe



Third, the monitoring terminal installation Nrpe

1, installation Nrpe

[Email protected] ~]# tar xf nrpe-2.15.tar.gz [[email protected] ~]# CD Nrpe-2.15[[email protected] nrpe-2.15]#./configu Re >--with-nrpe-user=nagios >--with-nrpe-group=nagios >--with-nagios-user=nagios >--with-nagios-group= Nagios >--enable-command-args >--enable-ssl[[email protected] nrpe-2.15]# make All[[email protected] nrpe-2.15]# When the make install-plugin# installation is complete, the Check_nrpe plugin is generated under the libexec of the Nagios installation directory [[email protected] ~]# cd/usr/local/nagios/libexec/[ [Email protected] libexec]# ll-d check_nrpe-rwxrwxr-x. 1 Nagios nagios 76769 September 08:07 Check_nrpe


2, the use of Check_nrpe

[[Email protected] libexec]# ./check_nrpe -hnrpe plugin for nagioscopyright   (c)  1999-2008 Ethan Galstad  ([email protected]) version: 2.15last  modified: 09-06-2013license: gpl v2 with exemptions  (-l for more  Info) Ssl/tls available: anonymous dh mode, openssl 0.9.6 or higher &NBSP;REQUIREDUSAGE:&NBSP;CHECK_NRPE&NBSP;-H&NBSP;&LT;HOST&GT;&NBSP;[&NBSP;-B&NBSP;&LT;BINDADDR&GT;&NBSP;]  [-4] [-6] [-n] [-u] [-p <port>] [-t <timeout>] [-c  <command>] [-a <arglist...>]Options: -n          = Do no use SSL -u          = make socket timeouts return an unknown state instead of  critical 
Remote Linux hosts are monitored via Nrpe using the Chech_nrpe plugin with the following syntax: Check_nrpe-h 


3. Define commands, hosts, services



This article is from the "Zheng" blog, make sure to keep this source http://467754239.blog.51cto.com/4878013/1558897

Nagios uses Nrpe to monitor Linux hosts

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.