部署nrpe
(一)安装nrpe
tar zxvf nrpe-2.8.1.tar.gz
cd nrpe-2.8.1
./configure -prefix=/usr/local/nrpe
make
make install
注:如果在其他被监控机安装nrpe,需要添加系统用户nagios.
(二)复制文件
安装完nrpe后,在安装目录/usr/local/nrpe/libexec只有一个文件check_nrpe,而在nagios插件目录,却缺少这个文件,因此需要把这个文件复制到nagios插件目录;同样,因为nrpe需要调用的诸如check_disk等插件在自己的目录没有,可是这些文件确是nagios插件所存在的,所以也需要从nagios目录复制一份过来。我们把复制过程列举出来:
cp /usr/local/nrpe/libexec/check_nrpe /usr/local/nagios/libexec
cp /usr/local/nagios/libexec/check_disk /usr/local/nrpe/libexec
cp /usr/local/nagios/libexec/check_load /usr/local/nrpe/libexec
cp /usr/local/nagios/libexec/check_ping /usr/local/nrpe/libexec
cp /usr/local/nagios/libexec/check_procs /usr/local/nrpe/libexec
(三)配置nrpe
安装完nrpe以后,在安装目录并没有可用的配置文件,但我们只需把解压目录的样例文件复制到安装目录,然后修改这个文件.
1、 mkdir /usr/local/nrpe/etc
2、 cp sample-config/nrpe.cfg /usr/local/nrpe/etc
3、 修改配置文件/usr/local/nrpe/etc/nrpe.cfg.该过的地方用粗体显示:
pid_file=/var/run/nrpe.pid
server_port=5666
#以单独的守护进程运行
server_address=59.26.240.63
nrpe_user=nagios
nrpe_group=nagios
allowed_hosts=127.0.0.1,59.26.240.63
dont_blame_nrpe=0
debug=0
command_timeout=60
connection_timeout=300
# The following examples use hardcoded command arguments...
command[check_users]=/usr/local/nrpe/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nrpe/libexec/check_load -w 15,10,5 -c 30,25,20
#command[check_hda1]=/usr/local/nrpe/libexec/check_disk -w 20 -c 10 -p /dev/hda1
command[check_df]=/usr/local/nrpe/libexec/check_disk -w 20 -c 10
command[check_zombie_procs]=/usr/local/nrpe/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nrpe/libexec/check_procs -w 150 -c 200
command[check_ips]=/usr/local/nrpe/libexec/ip_conn.sh 8000 10000
说明:
● allowed_hosts=127.0.0.1,59.26.240.63 必须允许nagios监控服务器可以访问。
● command[check_df]=/usr/local/nrpe/libexec/check_disk -w 20 -c 10 检查整个服务器的磁盘利用率;如果是freebsd系统,因为其/dev分区为100%,需要排除这个分区,因此其命令行应该为 "command[check_df]=/usr/local/nrpe/libexec/check_disk -x /dev -w 20 -c 10"。
● command[check_ips]=/usr/local/nrpe/libexec/ip_conn.sh 8000 10000 ip连接数,ip_conn.sh脚本需要自己写,下面给出脚本的内容:
#!/bin/sh
#if [ $# -ne 2 ]
#then
# echo "Usage:$0 -w num1 -c num2"
#exit 3
#fi
ip_conns=`netstat -an | grep tcp | grep EST | wc -l`
if [ $ip_conns -lt $1 ]
then
echo "OK -connect counts is $ip_conns"
exit 0
fi
if [ $ip_conns -gt $1 -a $ip_conns -lt $2 ]
then
echo "Warning -connect counts is $ip_conns"
exit 1
fi
if [ $ip_conns -gt $2 ]
then
echo "Critical -connect counts is $ip_conns"
exit 2
fi
我在nrpe配置文件nrpe.cfg把脚本所需的两个参数写上了,因此这个脚本就不需判 断两个参数输入值的情况。只要当前ip连接数大于8000,系统就发warning报警,超过10000,则发"critical"报警信息。把这个脚本放在目录/usr/local/nrpe/libexec下,并给于执行权限。
(四)、启动nrpe服务并检验其配置
1、以独立守护进程启动nrpe服务 /usr/local/nrpe/bin/nrpe -c /usr/local/nrpe/etc/nrpe.cfg -d
2、通过察看系统日志,正常启动可以看到如下输出:
Mar 2 21:07:18 MONITOR nrpe[23823]: Starting up daemon
Mar 2 21:07:18 MONITOR nrpe[23823]: Listening for connections on port 5666
Mar 2 21:07:18 MONITOR nrpe[23823]: Allowing connections from: 127.0.0.1,59.26.240.63
察看端口,也能看见5666端口处于监听状态:
[root@MONITOR nrpe]# netstat -an
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 59.26.240.63:5666 0.0.0.0:* LISTEN
察看进程:
[root@MONITOR nrpe]#ps aux | grep nrpe | grep -v grep
nagios 23823 0.0 0.0 4864 924 ? Ss 21:07 0:00 bin/nrpe -c etc/nrpe.cfg -d
3、检查插件功能
(1)检查nrpe服务
[root@MONITOR nrpe]# libexec/check_nrpe -H 59.26.240.63
NRPE v2.8.1
(2)通过nrpe检查主机资源
[root@MONITOR nrpe]# libexec/check_nrpe -H 59.26.240.63 -c check_df
DISK OK - free space: / 8241 MB (77% inode=98%); /var 5239 MB (95% inode=99%); /usr 11971 MB (86% inode=97%); /dev/shm 1013 MB (100% inode=99%);| /=2417MB;11218;11228;0;11238 /var=273MB;5792;5802;0;5812 /usr=1807MB;14508;14518;0;14528 /dev/shm=0MB;993;1003;0;1013
[root@MONITOR nrpe]#libexec/check_nrpe -H 59.26.240.63 -c check_ips
OK -connect counts is 13956
遇到问题:CHECK_NRPE: Error - Could not complete SSL handshake
解决: 检查下你的 插件文件的权限。 如果是本地执行 check_nrpe -H 那么记得,把本地主机的ip 记录在nrpe 配置文件里面的 allow_host 里面。
如果这行了 libexec/check_nrpe -H 59.26.240.63 -c check_df 能成功。那么就可以去 nagios 监控主机上配置了
我的nagios 监控服务是 FB系统。 所以 首先进入 commands.cfg 文件添加 check_nrpe 命令
define command{
command_name check_192.168.1.244.load
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c check_load
}
然后 到 localhost.cfg 文件里配置要监控的主机 和 要监控的服务
define host{
use freebsd-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the freebsd-server host template definition.
#notifications_enabled 1 ; Host notifications are enabled
#notification_period 24x7 ; Send host notifications at any time
host_name beihai365_244
alias beihai365_244
address 192.168.1.244
}
define service{
use local-service ; Name of service template to use
host_name beihai365_244
service_description check_load
contact_groups admins
check_command check_192.168.1.244.load
}
然后 reload
就OK了。。
分享到:
相关推荐
nrpe及配置說明,非常詳細,下載會有很大的驚喜
服务器状态监控软件安装部署和配置指导文档
NAGIOS的监控代理,NRPE 2.15.
nrpe-2.15
nrpe-2.13.tar.gz nrpe-2.13 nrpe
nrpe 2.15 .tar.gz格式。 site:http://www.nrpe.org nrpe-2.15.tar.gz 源代码。
很详细。对网上所有相关资料的整合。特别是nagios.cfg的详细解释
Nagios+Centreon+Nrpe+NSClient++完全配置笔记
当前2018年,nagios监控客户端需要安装的NRPE,最新3.2.1版本手册,英文版
naigos 集群套件 远程监控管理模块 nrpe 。。。
icinga-nrpe.2.14.tar.gz icinga客户端安装包 安装在被检测服务器端 service icinga-nrpe start
nrpe-3.0.1.tar.gz
nagios监控mysql服务器: 1、建立专用数据库: [root@svr3 ~]# /usr/local/webserver/mysql/bin/mysql -u root -p Enter password: Welcome to the MySQL monitor.... or \g. Your MySQL connection id is 51910 ...
安装包已经 安装说明 具体如下 nagios-plugins-2.2.1.tar.gz nagios-plugins-2.2.1.tar.gz xinetd-2.3.14-40.el6.x86_64.rpm 安装说明.txt 、、、、、、、、、、、
一个全攻略的Nagios+Centreon+Nrpe+PHP+Mysql+NSClient完全安装
nrpe-3.2.1.tar.gz 。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
nagios主动检测插件,主要实现nagios的主动检测机制,网上其他地方没有哦!
资源名称:Nagios各组件简述及nrpe详解资源截图: 资源太大,传百度网盘了,链接在附件中,有需要的同学自取。
NRPE是监控软件nagios的一个扩展,它被用于被监控的服务器上,向nagios监控平台提供该服务器的一些本地的情况。例如,cpu负载、内存使用、硬盘使用等等。NRPE可以称为nagios的for linux 客户端。
网络资源监视器(组件)