Nagios Remote Plugin Executor (NRPE)是Nagios生态中用于远程执行监控任务的代理程序,由Nagios Enterprises官方团队维护。其核心功能是通过加密通信机制,允许监控服务器在远端主机上执行本地插件,实现对CPU、磁盘、进程等资源的透明化监控。
官方下载渠道:
1. GitHub Releases页面
2. 预编译包
1. 安全传输机制
2. 跨平台兼容性
3. 模块化架构
4. 低资源消耗
bash
安装编译依赖
sudo yum install -y gcc glibc openssl-devel make autoconf CentOS/RHEL
sudo apt install -y build-essential libssl-dev autoconf Debian/Ubuntu
bash
wget
tar xzf nrpe-4.1.3.tar.gz
cd nrpe-4.1.3
bash
生成配置脚本(GitHub源码需先运行autoconf)
autoconf
/configure with-nrpe-user=nagios with-nrpe-group=nagios enable-ssl
关键参数说明:
bash
make all
sudo make install-plugin 安装check_nrpe到监控端
sudo make install-daemon 安装nrpe守护进程到被监控端
sudo make install-daemon-config 生成配置文件
编辑`/usr/local/nagios/etc/nrpe.cfg`:
ini
allowed_hosts=192.168.1.100 监控服务器IP
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
bash
独立守护进程模式
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
或通过systemd管理(推荐)
sudo cp contrib/nrpe.service /etc/systemd/system/
sudo systemctl enable now nrpe
1. 端口连通性测试
bash
telnet 被监控端IP 5666 确认端口开放
2. 插件通信验证
在监控端执行:
bash
/usr/local/nagios/libexec/check_nrpe -H 被监控端IP -c check_load
成功返回格式:`OK
3. 常见错误处理
1. 自定义监控项
在`nrpe.cfg`中添加`command[]`指令,例如监控MySQL:
ini
command[check_mysql]=/usr/local/nagios/libexec/check_mysql -H localhost -u monitor -p P@ssw0rd
2. 安全加固方案
1. 备份现有配置(`nrpe.cfg`)
2. 下载新版源码并重新编译
3. 执行`./update-cfg.pl`迁移旧配置
:NRPE作为Nagios生态的核心组件,其官方源码遵循标准化开发流程,通过合理的编译参数与安全配置,可快速构建企业级监控网络。建议持续关注GitHub Release页面的安全更新,确保监控体系长期稳定运行。