Nagios Learning Note Four: Monitoring remote Linux hosts based on Nrpe

Source: Internet
Author: User

1, Nrpe Introduction

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

NRPE (Nagios Remote Plugin Executor) is a daemon that runs the instrumentation command on the remote server, which allows the Nagios monitoring side to trigger the detection command on the remote host based on the installation and output the test 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.

2, the installation configuration is monitored end

1) Add Nagios users First

# useradd-s/sbin/nologin Nagios

2) Nrpe relies on nagios-plugins, so it needs to be installed first

# tar zxf nagios-plugins-1.4.15.tar.gz

# CD nagios-plugins-1.4.15

#./configure--with-nagios-user=nagios--with-nagios-group=nagios

# make All

# make instal

3) Install Nrpe

# TAR-ZXVF Nrpe-2.12.tar.gz

# CD Nrpe-2.12.tar.gz

#./configure--with-nrpe-user=nagios \

--with-nrpe-group=nagios \

--with-nagios-user=nagios \

--with-nagios-group=nagios \

--enable-command-args \

--enable-ssl

# make All

# Make Install-plugin

# Make Install-daemon

# Make Install-daemon-config

4) Configuration Nrpe

# vim/usr/local/nagios/etc/nrpe.conf

Log_facility=daemon

Pid_file=/var/run/nrpe.pid

server_address=172.16.100.11

server_port=5666

Nrpe_user=nagios

Nrpe_group=nagios

allowed_hosts=172.16.100.1 #允许哪些nagios服务端查询

Command_timeout=60

connection_timeout=300

Debug=0 #是否打开日志, 0 means no open, 1 means open, the log is in message

Dont_blame_nrpe=1 #是否允许传递参数, 1 means run, 0 means not allowed

The above configuration directives can be used to see the meaning of the name, therefore, the configuration process according to the actual needs of the changes can be. Where specific instructions are required to define the IP address of the monitoring side that is allowed by the allowed_hosts directive.

5) Start Nrpe

#/usr/local/nagios/bin/nrpe-c/usr/local/nagios/etc/nrpe.cfg–d

To facilitate the startup of the Nrpe service, you can define the following as a/etc/init.d/nrped script:

#!/bin/bash

# chkconfig:2345 88 12

# Description:nrpe DAEMON

Nrpe=/usr/local/nagios/bin/nrpe

Nrpeconf=/usr/local/nagios/etc/nrpe.cfg

Case "$" in

Start

Echo-n "Starting NRPE daemon ..."

$NRPE-C $NRPECONF-D

echo "Done."

;;

Stop

Echo-n "Stopping NRPE daemon ..."

Pkill-u Nagios Nrpe

echo "Done."

;;

Restart

$ stop

Sleep 2

$ start

;;

*)

echo "Usage: $ start|stop|restart"

;;

Esac

Exit 0

Alternatively, you can create a Nrpe file in the/etc/xinetd.d directory to make it a service based on a non-independent daemon, with the following file contents:

Service Nrpe

{

Flags = Reuse

Socket_type = Stream

wait = no

user = Nagios

Group = Nagios

Server =/usr/local/nagios/bin/nrpe

Server_args =-c/etc/nagios/nrpe.cfg-i

Log_on_failure + = USERID

Disable = no

}

In this case, starting the Nrpe process needs to be done by restarting the xinetd.

6) Configure objects that allow remote host monitoring

On the monitored side, services or resources that can be monitored through nrpe need to be defined by using the nrpe.conf File command, and the syntax format for the defined command is: Command[<command_name>]=<command_to_execute >. Like what:

When Nrpe receives the command, it actually invokes the command provided by the plugin, returning the result to Nrpe, so the command sent by the Nagios server is the defined command

Command[check_rootdisk]=/usr/local/nagios/libexec/check_disk-w 20%-C 10%-P/

Command[check_swap]=/usr/local/nagios/libexec/check_disk-w 40%-C 20%

Command[check_sensors]=/usr/local/nagios/libexec/check_sensors

Command[check_users]=/usr/local/nagios/libexec/check_users-w 10-c 20

Command[check_load]=/usr/local/nagios/libexec/check_load-w 10,8,5-c 20,18,15

Command[check_zombies]=/usr/local/nagios/libexec/check_procs-w 5-c 10-s Z

Command[check_all_procs]=/usr/local/nagios/libexec/check_procs-w 150-C 200

Command[check_all_procs]=/usr/local/nagios/libexec/check_procs-w $ARG 1$-C $ARG 2$

Modify to how parameters can be passed

Nagios Learning Note Four: Monitoring remote Linux hosts based on Nrpe

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.