linux环境中安装NRPE插件执行远程"本地资源"检查?NRPE安装?
需求描述:
在安装完nagios之后,需要对本地资源进行监控,比如磁盘空间的使用,进程数,swap空间,等等.这些都不是通过网络提供出来的,
所以,都是本地资源,可以通过NRPE插件实现在客户端中采集数据,然后通过网络传递给监控服务器,由监控服务器实现对传递过来
的数据进行判断.
环境描述:
操作系统:RedHat6.6 x64
安装过程:
----客户端----
1.关闭selinux
[root@testvm02 ~]# sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
[root@testvm02 ~]# getenforce
Permissive
2.下载,上传nagios-plugins插件和nrpe插件
nagios-plugins下载地址:https://www.nagios.org/downloads/nagios-plugins/
nrpe下载地址:https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
[root@testvm03 software]# ls -ltr
total
-rw-r--r--. root root Jul : nrpe-2.15.tar.gz
-rw-r--r--. root root Jul : nagios-plugins-2.2..tar.gz
3.安装nrpe之前需要先安装nagios-plugins
3.1安装需需要的软件包
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
3.2解压,编译,安装
[root@testvm03 software]# tar -zxf nagios-plugins-2.2..tar.gz
[root@testvm03 software]# cd nagios-plugins-2.2.
[root@testvm03 nagios-plugins-2.2.]# ./configure
[root@testvm03 nagios-plugins-2.2.1]# make
[root@testvm03 nagios-plugins-2.2.1]# make install
4.创建nagios用户组,用户
[root@testvm03 nagios-plugins-2.2.]# groupadd nagios
[root@testvm03 nagios-plugins-2.2.]# useradd -r -g nagios nagios
5.解压,编译,安装nrpe
[root@testvm03 software]# tar zxf nrpe-2.15.tar.gz
[root@testvm03 software]# cd nrpe-2.15
[root@testvm03 nrpe-2.15]# ./configure
[root@testvm03 nrpe-2.15]# make all
[root@testvm03 nrpe-2.15]# make install-daemon #安装nrpe命令.
[root@testvm03 nrpe-2.15]# make install-daemon-config #安装nrpe配置文件
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 644 -o nagios -g nagios sample-config/nrpe.cfg /usr/local/nagios/etc
6.编辑nrpe.cfg(/usr/local/nagios/etc/nrpe.cfg)配置文件,增加监控主机的地址
allowed_hosts=127.0.0.1,192.168.53.25 #找到allowed_hosts,增加监控主机的地址.
7.将nrpe的启动脚本加入到/etc/init.d目录,加入到开机启动
[root@testvm03 etc]# cd /opt/software/nrpe-2.15
[root@testvm03 nrpe-2.15]# cp init-script /etc/init.d/nrpe
[root@testvm03 nrpe-2.15]# chmod +x /etc/init.d/nrpe
[root@testvm03 nrpe-2.15]# chkconfig --add nrpe
[root@testvm03 nrpe-2.15]# chkconfig --list | grep nrpe
nrpe :off :off :on :on :on :on :off
8.启动nrpe服务,查看程序监听的端口
[root@testvm03 nrpe-2.15]# service nrpe start
Starting nrpe: [ OK ]
[root@testvm03 nrpe-2.15]# ps -ef | grep nrpe
nagios : ? :: /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
root : pts/ :: grep nrpe [root@testvm03 nrpe-2.15]# netstat -ntlp | grep nrpe
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 23979/nrpe #nrpe监听端口是5666
tcp 0 0 :::5666 :::* LISTEN 23979/nrpe
----监控服务器----
1.关闭selinux
[root@testvm02 ~]# sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config
[root@testvm02 ~]# getenforce
Permissive
2.上传nrpe包,解压,编译,安装
[root@testvm02 softwares]# tar zxf nrpe-2.15.tar.gz
[root@testvm02 softwares]# cd nrpe-2.15
[root@testvm02 nrpe-2.15]# ./configure
[root@testvm02 nrpe-2.15]# make all
[root@testvm02 nrpe-2.15]# make install-plugin #安装check_nrpe插件而不是nrpe命令,要注意.
3.检查nrpe_check插件已经正确安装
[root@testvm02 nrpe-2.15]# ls /usr/local/nagios/libexec/check_nrpe
/usr/local/nagios/libexec/check_nrpe
4.在nagios的commands.cfg中加入nrpe命令
define command {
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
#特别注意不要有中文的中划线
5.创建主机配置文件,修改cfg文件的权限
define host {
use linux-server
host_name 192.168.53.26
address 192.168.53.26
}
define service {
use generic-service,graphed-service ; Name of service template to use
host_name 192.168.53.26
service_description System_Load
check_command check_nrpe!check_load
}
define service {
use generic-service,graphed-service
host_name 192.168.53.26
service_description disk_usage
check_command check_nrpe!check_disk
}
[root@testvm02 objects]# chown nagios:nagios 192.168.53.26.cfg
7.创建nagios配置文件的目录,将配置文件归类存放
mkdir -p /usr/local/nagios/etc/objects/commands
mkdir -p /usr/local/nagios/etc/objects/timeperiods
mkdir -p /usr/local/nagios/etc/objects/contacts
mkdir -p /usr/local/nagios/etc/objects/contactgroups
mkdir -p /usr/local/nagios/etc/objects/hosts
mkdir -p /usr/local/nagios/etc/objects/hostgroups
mkdir -p /usr/local/nagios/etc/objects/services
mkdir -p /usr/local/nagios/etc/objects/servicegroups
mkdir -p /usr/local/nagios/etc/objects/templates
mkdir -p /usr/local/nagios/etc/objects/others 将文件归类到具体的路径中: [root@testvm02 objects]# ls -ltr
total 96
-rw-rw-r--. 1 nagios nagios 1797 Jul 31 11:38 contacts.cfg
-rw-rw-r--. 1 nagios nagios 3512 Jul 31 11:38 timeperiods.cfg
-rw-rw-r--. 1 nagios nagios 4074 Jul 31 11:38 windows.cfg
-rw-rw-r--. 1 nagios nagios 3001 Jul 31 11:38 printer.cfg
-rw-rw-r--. 1 nagios nagios 3484 Jul 31 11:38 switch.cfg
-rw-rw-r--. 1 nagios nagios 12869 Jul 31 14:44 templates.cfg
-rw-rw-r--. 1 nagios nagios 4905 Jul 31 14:47 localhost.cfg
-rw-rw-r--. 1 nagios nagios 7120 Jul 31 16:54 commands.cfg
-rw-r--r--. 1 nagios nagios 446 Jul 31 17:03 192.168.53.26.cfg
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 commands
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 timeperiods
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 contacts
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 contactgroups
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 hosts
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 hostgroups
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 services
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 servicegroups
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 templates
drwxr-xr-x. 2 root root 4096 Jul 31 17:09 others
[root@testvm02 objects]# mv 192.168.53.26.cfg hosts/
[root@testvm02 objects]# mv localhost.cfg hosts/
[root@testvm02 objects]# mv commands.cfg commands
[root@testvm02 objects]# mv windows.cfg switch.cfg printer.cfg others/
[root@testvm02 objects]# mv templates.cfg templates/
[root@testvm02 objects]# mv timeperiods.cfg timeperiods/
[root@testvm02 objects]# mv contacts.cfg contacts
8.修改nagios.cfg配置文件,增加cfg_dir配置,将cfg_file的都注释掉
cfg_dir=/usr/local/nagios/etc/objects/commands
cfg_dir=/usr/local/nagios/etc/objects/timeperiods
cfg_dir=/usr/local/nagios/etc/objects/contacts
cfg_dir=/usr/local/nagios/etc/objects/contactgroups
cfg_dir=/usr/local/nagios/etc/objects/hosts
cfg_dir=/usr/local/nagios/etc/objects/hostgroups
cfg_dir=/usr/local/nagios/etc/objects/services
cfg_dir=/usr/local/nagios/etc/objects/servicegroups
cfg_dir=/usr/local/nagios/etc/objects/templates #不配置others目录,目的是对这些其他的设备不进行监控
# You can specify individual object config files as shown below:
#cfg_file=/usr/local/nagios/etc/objects/commands.cfg
#cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
#cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
#cfg_file=/usr/local/nagios/etc/objects/templates.cfg
# Definitions for monitoring the local (Linux) host
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
9.重启nagios
[root@testvm02 objects]# service nagios restart
Running configuration check... Stopping nagios: .done.
Starting nagios: Running configuration check... done.
10.查看监控页面


备注:系统负载已经能够正常的检查了.但是NRPE: Command 'check_disk' not defined,有这个错误.
11.NRPE: Command 'check_disk' not defined 处理,在客户端的nrpe.cfg中配置check_disk命令及告警
command[check_disk]=/usr/local/nagios/libexec/check_disk -w % -c % -p / -C -w % -c % -p /boot #指定检查特定的分区,设定告警,验证的百分比.
#command后面的中括号内,就是定义的nrpe的命令.在server端调用的就是这个命令,然后在客户端执行,也可理解这个命令就是等号后面一长串的别名.
12.重启客户端的nrpe
[root@testvm03 etc]# service nrpe restart
Shutting down nrpe: [ OK ]
Starting nrpe: [ OK ]
13.查看nagios的页面

备注:已经能够监控到远程的磁盘空间使用情况了,并且设置了告警,其他的命令可以模拟这个.具体的调度命令要在libexec目录中.或者自行安装插件和命令.
另:
- 针对磁盘空间设置告警值,检查哪个目录都是在客户端的nrpe.cfg文件中配置的.其他的检查也是在客户端配置告警百分比
- 监控端,不需要启动nrpe进程,nrpe进程只是在客户端启动
文档创建时间:2018年7月31日18:05:31
linux环境中安装NRPE插件执行远程"本地资源"检查?NRPE安装?的更多相关文章
- (3)ElasticSearch在linux环境中安装与配置head插件
1.简介 ElasticSearch-Head跟Kibana一样也是一个针对ElasticSearch集群操作的API的可视化管理工具,它提供了集群管理.数据可视化.增删改查.查询语句等功能,最重要还 ...
- linux环境中,多个命令之间,通过&& ||执行,命令之间执行的逻辑是什么?
需求描述: 最近在写一个脚本的时候,要判断一个文件是否存在,有怎么样,没有就创建,这个时候 看到了一个test 结合 || 或者 &&的写法,就查看了下资料记录下是怎么个玩法. 操作过 ...
- linux环境中安装ftp服务
需求说明: 今天项目中有一个新的需求,需要在linux环境中搭建一个ftp服务,在此记录下. 操作过程: 1.通过yum的方式安装ftp服务对应的软件包 [root@testvm01 ~]# yum ...
- 【事件中心 Azure Event Hub】在Linux环境中(Ubuntu)安装Logstash的简易步骤及配置连接到Event Hub
在文章([事件中心 Azure Event Hub]使用Logstash消费EventHub中的event时遇见的几种异常(TimeoutException, ReceiverDisconnected ...
- abp框架angular 项目docker 手动部署到Linux环境中
1.https://aspnetboilerplate.com/Templates 2.后端项目发布,在publish中abp默认已经存在DockerFile文件 3.修改后端文件中的DockerFi ...
- Linux环境中Openfire安装指南
Linux环境中Openfire安装指南 安装环境: 安装软件:Openfire 4_1_0 http://download.igniterealtime.org/openfire/openfire_ ...
- 理解 Linux 网络栈(2):非虚拟化Linux 环境中的 Segmentation Offloading 技术
本系列文章总结 Linux 网络栈,包括: (1)Linux 网络协议栈总结 (2)非虚拟化Linux环境中的网络分段卸载技术 GSO/TSO/UFO/LRO/GRO (3)QEMU/KVM + Vx ...
- [软件测试]Linux环境中简单清爽的Google Test (GTest)测试环境搭建(初级使用)
本文将介绍单元测试工具google test(GTEST)在linux操作系统中测试环境的搭建方法.本文属于google test使用的基础教程.在linux中使用google test之前,需要对如 ...
- Dev环境中的集成测试用例执行时上下文环境检查(实战)
Dev环境中的集成测试用例执行时上下文环境检查(实战) Microsoft.NET 解决方案,项目开发必知必会. 从这篇文章开始我将分享一系列我认为在实际工作中很有必要的一些.NET项目开发的核心技术 ...
随机推荐
- Knockout开发中文API系列4–绑定关键字
目的 Visible绑定通过绑定一个值来确定DOM元素显示或隐藏 示例 <div data-bind="visible: shouldShowMessage"> You ...
- 基于云端的通用权限管理系统,SAAS服务,基于SAAS的权限管理,基于SAAS的单点登录SSO,企业单点登录,企业系统监控,企业授权认证中心
基于云端的通用权限管理系统 SAAS服务 基于SAAS的权限管理 基于SAAS的单点登录SSO 基于.Net的SSO,单点登录系统,提供SAAS服务 基于Extjs 4.2 的企业信息管理系统 基于E ...
- Gojs简单例子
前台代码: <!DOCTYPE html> <html xmlns:th="http://www.thymeleaf.org"> <head> ...
- WebRTC 源码分析(二):安卓预览
有过一定相机开发经验的朋友可能会疑惑,预览还有什么好分析的,不是直接 camera.setPreviewDisplay 或者 camera.setPreviewTexture 就能在 SurfaceV ...
- bootstrap底部消息提示插件
http://www.bootcss.com/p/messenger/ 具体效果下载插件查看
- How to install SharePoint 2013 on Windows Server 2012 R2
[Update 26.02.2014] Many thanks to everybody commented on this post. As Falk already mentioned in th ...
- Java容器有哪些?
网易面试: 问:Java容器有哪些,你聊一聊吧 Java容器: 数组,String,java.util下的集合容器 数组长度限制为 Integer.Integer.MAX_VALUE; String的 ...
- Global Pose Estimation with an Attention-based Recurrent Network
related work包含比较多,对SLAM和最近神经网络对于定位的工作介绍比较多.
- C艹复合类型(字符串)
在C艹中有两种字符串形式, 一种是C-风格, 另一种是C艹风格的 初始化: char str[10] = {'a', 'c', 'd', '\0'};char str[20]= “aaa”; stri ...
- Java Web知识梳理
今天给内部做了个培训,貌似搞错了对象,不该对新人讲这么原理性的东西. anyway,还是放上来吧,不知道有没有人能理清其中的逻辑 ^ _ ^ 问题:为什么要用tomcattomcat: servlet ...