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项目开发的核心技术 ...
随机推荐
- Lamda表达式的参数捕获,太酷了
lamda表达式有了参数捕获这个功能,让Action这个委托变得无所不能.Action委托就是无参数,无返回值的一个代理类型. 它只能对应于下面这种类型的函数声明. public void Funct ...
- hbase 学习(十六)系统架构图
HBase 系统架构图 组成部件说明 Client: 使用HBase RPC机制与HMaster和HRegionServer进行通信 Client与HMaster进行通信进行管理类操作 Client与 ...
- JDBC-批处理操作
javaweb学习总结(三十六)——使用JDBC进行批处理 在实际的项目开发中,有时候需要向数据库发送一批SQL语句执行,这时应避免向数据库一条条的发送执行,而应采用JDBC的批处理机制,以提升执行效 ...
- SpringCloud 详解配置刷新的原理 使用jasypt自动加解密后 无法使用 springcloud 中的自动刷新/refresh功能
之所以会查找这篇文章,是因为要解决这样一个问题: 当我使用了jasypt进行配置文件加解密后,如果再使用refresh 去刷新配置,则自动加解密会失效. 原因分析:刷新不是我之前想象的直接调用conf ...
- 目录_Java内存分配(直接内存、堆内存、Unsafel类、内存映射文件)
1.Java直接内存与堆内存-MarchOn 2.Java内存映射文件-MarchOn 3.Java Unsafe的使用-MarchOn 简单总结: 1.内存映射文件 读文件时候一般要两次复制:从磁盘 ...
- WPF/SL: lazy loading TreeView
Posted on January 25, 2012 by Matthieu MEZIL 01/26/2012: Code update Imagine the following scenario: ...
- Mininet的介绍&安装
Mininet的介绍 Mininet是一个强大的网络仿真平台,通过这个这个平台,我们可以很方便的模拟真实环境中的网络操作与架构.当前SDN/OpenFlow发展的如火如荼,但是在真实网络中又不可以进行 ...
- 自然语言交流系统 phxnet团队 创新实训 个人博客 (六)
讯飞的语音sdk是需要申请的,地址是:http://dev.voicecloud.cn/developer.php?vt=1 .申请一个讯飞的开发者账号,然后申请一个appid,申请的时候需要填写开发 ...
- FPGA中的时序分析(五)
时序约束实例详解 本篇博客结合之前的内容,然后实打实的做一个约束实例,通过本实例读者应该会实用timequest去分析相关的实例.本实例以VGA实验为基础,介绍如何去做时序约束. 首先VGA这种情况属 ...
- modelsim 出现此错误怎么办
笔者的电脑装成了win8的系统,然后像平常一样打开modelsim,这时跳出如下图的界面: 笔者的modelsim之前是安装过的,所以这个界面已经说明,当前的许可证没有安装好.解决上述问题的办法是重新 ...