Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use nrpe to transfer parameters to achieve more reasonable monitoring

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to use nrpe to pass parameters to achieve more reasonable monitoring. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Nagios monitoring is no stranger to everyone, I believe it works and the relationship between calls also have a certain understanding, in the production environment, monitoring linux server is obvious that we all know that we can use nrpe to detect indirect monitoring.

In fact, monitoring is divided into two types [understand the definition], one is active, such as ping, ssh, and so on, which only need the monitoring host to execute the corresponding command to achieve monitoring; the other is passive, that is, the monitoring host is abstracted for the client to receive data, and communicates with the monitored end with the help of nrpe plug-ins, such as disk, load, etc.

For active monitoring, it is naturally in the hands of the monitoring host to set and modify parameters, but for passive monitoring, for example, I wanted to monitor the root partition usage of the server in the past, but now I need to monitor the use of / home partition due to changes in the production environment, and maybe the alarm value used by my disk also needs to be modified. It is obviously not a wise choice to log in to the imprisoned host to modify the corresponding parameters. If we can change the monitoring host from passive to active, and get the power to modify the parameters, wouldn't it be very good? here's a configuration explanation for your reference.

If the monitoring host wants to be active, it is obvious that the monitored host is allowed to pass parameters, so it is necessary to make some efforts on the monitored host.

1. Recompile nrpe on the monitored host

. / configure-- enable-command-args

Make all

Make install-plugin

Make install-daemon

Make install-daemon-config

2. Allow parameters to be passed on

Dont_blame_nrpe=0-"dont_blame_nrpe=1"

3. Set detection instructions with parameters [example]

Commander [check _ disk] = / usr/local/nagios/libexec/check_disk-w$ARG1 $- c $ARG2 $- p $ARG3 $

4 、 reload nrpe

Kil-HUP `ps-ef | grep nrpe | grep-v grep | awk' {print $2}'`

# # #

The following is to monitor the operation on the host.

Note that the rest of the configuration of the monitoring host is not described here, only those related to the parameter transfer configuration are briefly described.

1. Execute the command test directly first:

[root@localhost libexec] # / usr/local/nagios/libexec/check_nrpe-H 192.168.15.183-c check_disk-a 20% 15% /

DISK OK-free space: / 14250 MB (79% inode=91%); | / = 3645MB

2. Define the command template

Vi / usr/local/nagios/etc/objects/commands.cfg

Add

Define command {

Command_name check_remote_disk

Command_line $USER1 $/ check_nrpe-H $HOSTADDRESS$-c check_disk-a $ARG1 $$ARG2 $$ARG3 $

}

3. Modify the host configuration file

Vi / usr/local/nagios/etc/objects/services.cfg

Modify and add

Define service {

Use generic-service

Host_name centos6

Service_description check_load

Check_command checkboxes remoteware load20% "10%" /

}

4. Check syntax and overload nagios

[root@localhost~] # / usr/local/nagios/bin/nagios-v / usr/local/nagios/etc/nagios.cfg

[root@localhost~] # service nagios reload

Attach the installation and initialization script of the monitored host

Installation script:

#! / bin/bash#install nagios-plugins,nrpe#auth colynn.liuecho 'install nagios-plugins Nrpe....'wget-t 3-T 15 http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gzwget-t 3-T 15 http://nchc.dl.sourceforge.net/project/nagiosplug/nagiosplug/1.4.13/nagios-plugins-1.4.13.tar.gzuseradd nagios- s / sbin/nologin-Mtar zxf nagios-plugins-1.4.13.tar.gzcd nagios- Plugins-1.4.13./configure-- prefix=/usr/local/nagiosmake & & make installcd.. tar zxf nrpe-2.12.tar.gzcd nrpe-2.12sed-I '1657 s / ^ /\ /\ * /' src/nrpe.csed-I '1662 s / ^ /\ *\ / /' src/nrpe.c./configure-- enable-command-argsmake allmake install-pluginmake install-daemonmake install-daemon-configecho "/ usr/local/nagios/bin/nrpe-c / usr/local/nagios / etc/nrpe.cfg-d "> > / etc/rc.d/rc.localecho" DONE. "

More reasonable monitoring through parameters

#! / bin/bash#CONFFILE=/usr/local/nagios/etc/nrpe.cfgMASTERIP=192.168.15.188 cd / usr/local/nagios/etc/ & & cp nrpe.cfg nrpe.cfg.$ (date +% Y%m%d-%H). Bak & & echo "bakup is succeess nrpe.cfg.$ (date +% Y%m%d) -% H) .bak "sed-I" / allowed_hosts/s/allowed_hosts=127.0.*/allowed_hosts=127.0.0.1 ${MASTERIP} / "$CONFFILE & & echo" allowed_hosts add successfully "sed-I'/ dont_blame_nrpe/s/dont_blame_nrpe=0/dont_blame_nrpe=1/' $CONFFILEsed-I'/ ^ command\ [/ s / ^ / # /'$CONFFILEsed-I'/\ $/ s / ^ # /'$CONFFILE###start nrpePID= `ps-ef | grep nrpe | grep-v grep | awk'{print $2} '`if [- z $PID] then / usr/local/nagios/bin / nrpe-c / usr/local/nagios/etc/nrpe.cfg-delse kill-HUP $PID & & echo "reload nrpe is ok" fi Thank you for reading! This is the end of this article on "how to use nrpe to transmit parameters to achieve more reasonable monitoring". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report