NRPE监控插件基础

NRPE总共由两部分组成:
(1).check_nrpe插件,运行在监控主机上。
(2).NRPE daemon,运行在远程的linux主机上(通常就是被监控机)

整个的监控过程如下:
当Nagios需要监控某个远程linux主机的服务或者资源情况时:
1).nagios会运行check_nrpe插件,我们要在nagios配置文件中告诉它要检查什么.
2).check_nrpe插件会通过SSL连接到远程的NRPEdaemon.
3).NRPE daemon会运行相应的nagios插件来执行检查本地资源或服务.
4).NRPE daemon将检查的结果返回给check_nrpe插件,插件将其递交给nagios做处理.
注意:NRPE daemon需要nagios插件安装在远程被监控linux主机上,否则,daemon不能做任何的监控.

Nagios被监控端安装

Step1
安装nagios-plugin

useradd -s /sbin/nologin nagios

mkdir /usr/local/nagios

chown -R  nagios.nagios  /usr/local/nagios

tar -zxvf nagios-plugins-1.4.13.tar.gz

cd nagios-plugins-1.4.13

./configure  --prefix=/usr/local/nagios

make  && make install

这一步完成后会在/usr/local/nagios/下生成两个目录libexec和share

Step2

改变主目录权限

chown  -R  nagios.nagios  /usr/local/nagios

Step3

安装客户端的nrpe

tar -zxvf nrpe-2.12.tar.gz

cd  nrpe-2.12

./configure

make all

make install-plugin

make install-daemon

make install-daemon-config

Step4

配置nrpe信息
vi/usr/local/nagios/etc/nrpe.cfg
将allowed_hosts=127.0.0.1
修改成你的nagios服务器的ip

Step5

启动nrpe

/usr/local/nagios/bin/nrpe -c/usr/local/nagios/etc/nrpe.cfg -d

验证nrpe

netstat -an|grep 5666   察看是否在5666端口上监听

测试连通性

/usr/local/nagios/libexec/check_nrpe -Hlocalhost

察看是否能返回nrpv版本号,返回则正常!

Step6

vi /usr/local/nagios/etc/nrpe.cfg
可以看到里面监控对象
# The following examples use hardcoded command arguments...
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_hda1]=/usr/local/nagios/libexec/check_disk -w 20 -c 10 -p/dev/hda1
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -sZ
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

我们为了监控swap
在nrpe.cfg中添加
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
注意:添加监控新项目所用的命令都在客户端的nrpe.cfg中添加

添加之后再次启动nrpe

先杀掉后台进程,然后kill-9 进程号

/usr/local/nagios/bin/nrpe  -c  /usr/local/nagios/etc/nrpe.cfg –d

安装服务端nrpe

setp1

tar -zxvf nagios-nrpe_2.8.1.orig.tar.gz
cd nagios-nrpe_2.8.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios
 make all

make install-plugin
然后我们测试下连通性
/usr/local/nagios/libexec/check_nrpe -H 被监控端ip
如果返回nrpe版本号,那么正常!
如果返回拒绝连接!那么telnet ip 5666看是否正常

step2
配置nrpe添加支持:

由于nrpe外构组件,所以必须在nagios服务器端得commands.cfg中定义 [root@localhost etc]# vi /usr/local/nagios/etc/objects/commands.cfg
最下面添加
#check nrpe
define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H$HOSTADDRESS$ -c $ARG1$
        }

step3

配置要监控的linux主机和服务,这里我们集中到了一起 以甜豆为例
[root@localhost etc]# vi /usr/local/nagios/etc/nagios.cfg

中间添加
cfg_file=/usr/local/nagios/etc/objects/servers/td.cfg
配置文件的名字可以自己定义
=================================================

新建td.cfg
[root@localhost etc]# vi /usr/local/nagios/etc/objects/servers/td.cfg

添加
define host{

use             linux-server,hosts-pnp

host_name       td-h2

alias           td

address         x.x.x.x

hostgroups      td

max_check_attempts 10

}

define host{

use             linux-server,hosts-pnp

host_name       td-76

alias           td

address         x.x.x.x

hostgroups      td

max_check_attempts 10

}

define host{

use             linux-server,hosts-pnp

host_name       td-77

alias           td

address        x.x.x.x

hostgroups      td

max_check_attempts 10

}

define host{

use             linux-server,hosts-pnp

host_name       td-78

alias           td

address         x.x.x.x

hostgroups      td

max_check_attempts 10

}

--沿着上面格式,依次定义主机

--定义主机组

define hostgroup{

hostgroup_name  td

alias           td

members         td-h2,td-76,td-77,td-78

}

--定义服务

define service{

use                            local-service,services-pnp        ; Name of service template to use

host_name                       td-h2,td-76,td-77,td-78

service_description             check_tps

check_command                   nrpe!check_tps

}

define service{

use                            local-service,services-pnp        ; Name of service template to use

host_name                       td-h2,td-76,td-77,td-78

service_description             check_qps

check_command                   nrpe!check_qps

}

define service{

use                            local-service,services-pnp        ; Name of service template to use

host_name                       td-h2,td-76,td-77,td-78

service_description             check_connect

check_command                   nrpe!check_connect

}

配置完毕 检测配置文件是否正确

/usr/local/nagios/bin/nagios-v /usr/local/nagios/etc/nagios.cfg

正确的话,重新启动nagios

 

监控mysql服务安装插件check_mysql_health 插件,在被监控端

1)、在要监控mysql主机上面建立监控用户,用作mysql监控服务使用。赋权能使用即可,注意安全性

grant select,update,insert,delete on test.* to'my_perfor'@'localhost' identified by 'my_perfor';

2)、在nagios监控服务器上安装check_mysql_health插件.

tar -zxvf check_mysql_health-2.1.7.tar.gz

cd check_mysql_health-2.1.7

./configure --prefix=/usr/local/nagios--with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl

make && make install

安装 perl-DBD-MySQL包,同时yum工具会把需要的包都安装上包含perl-DBI

yum install -y perl-DBD-MySQL

安装完毕 可以验证一下查看一下索引情况

./check_mysql_health--socket=/usr/local/mysql/tmp/mysql.sock --port 3306 --username my_perfor --passwordmy_perfor --warning 180 --critical 220 --mode threads-connected

check_mysql_health依赖于软件包 注意64位和32位服务器的区别

yum install -y perl-DBD-MySQL  perl-DBI  # check_mysql_health使用需要这二个发安装包 如下在65位服务器上 安装 mysql版本5.0.8

yum 安装很方便,会安装上依赖的包

没有安装软件包运行 check_mysql_health时报以下错误

缺少 perl-dbd-mysql包,报如下错误

CRITICAL - cannot connect to information_schema.install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains:. /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi /usr/lib/perl5/5.8.8) at (eval13) line 3.

Perhaps the DBD::mysql perl module hasn't been fully installed,

or perhaps the capitalisation of 'mysql' isn't right.

Available drivers: DBM, ExampleP, File, Gofer, Proxy, Sponge.

at ./check_mysql_health line 1862

在32位服务器上可能会出现如下问题

在运行./check_mysql_health出现以下错误提示,

[root@file]# ./check_mysql_health    
-bash: ./check_mysql_health: yes: badinterpreter: No such file or directory

解决方法

因为check_mysql_health是用perl写的,将check_mysql_health的第一行由原来的#! yes -w修改为#!/usr/bin/perl,这样就OK了

Nagios+pnp4nagios+rrdtool 安装配置nagios被监控端NRPE配置(二)的更多相关文章

  1. Nagios+pnp4nagios+rrdtool 安装配置nagios(一)

    基于的软件版本 Apache-2.0.63  php-5.3.2 nagios-3.2.3  nagios-plugins-1.4.15  rrdtool-1.4.5 nrpe-2.12 pnp4na ...

  2. Nagios+pnp4nagios+rrdtool 安装配置为nagios添加自定义插件(三)

    nagios博大精深,可以以shell.perl等语句为nagios写插件,来满足自己监控的需要.本文写mysql中tps.qps的插件,并把收集到的结果以图形形式展现出来,这样输出的结果就有一定的要 ...

  3. Security基础(六):部署Zabbix监控平台、配置及使用Zabbix监控系统、自定义Zabbix监控项目、实现Zabbix报警功能

    一.部署Zabbix监控平台 目标: 本案例要求部署一台Zabbix监控服务器,一台被监控主机,为进一步执行具体的监控任务做准备: 在监控服务器上安装LAMP环境    修改PHP配置文件,满足Zab ...

  4. Spring学习总结(12)——Druid连接池及监控在spring配置

    Druid连接池及监控在spring配置如下: <bean id="dataSource" class="com.alibaba.druid.pool.DruidD ...

  5. Nagios的基本安装配置

    //////////////////////nagios//////////////////////nagios原理:http://www.linuxidc.com/Linux/2013-11/927 ...

  6. 1. Nagios和 NagiosQL安装及配置

    目录 1. Nagios 和 NagiosQL简介 2. Nagios+NagiosQL搭建环境说明 3. Nagios.Nagios-plugins和NagiosQL的安装 4. 配置NagiosQ ...

  7. CentOS 7.4 下安装部署Nagios监控系统详细攻略(三)

    Nagios是一个流行的电脑系统和网络监控程序,它检测主机和服务,当异常发生和解除时能提醒用户.它是基于GPLv2开发的开源软件,可免费获得及使用. nagios工作原理 nagios的功能是监控服务 ...

  8. nagios监控系统安装及配置

    Nagios通常由一个主程序(Nagios).一个插件程序(Nagios-plugins)和四个可选的ADDON(NRPE.NSCA.NSClient++和NDOUtils)组成.Ngios的监控工作 ...

  9. nagios 配置 check_traffic 流量监控模块(被监控端)

    安装软件包yum -y install net-snmp*chkconfig nrpe onchkconfig snmpd on 使用SCP命令拷贝 check_traffic.sh 到 / usr/ ...

随机推荐

  1. HDU 4974 A simple water problem(贪心)

    HDU 4974 A simple water problem pid=4974" target="_blank" style="">题目链接 ...

  2. win2003的IIS無法使用,又一次安裝提示找不到iisadmin.mfl文件

    我的系統是win2003 繁體版 sp2,現在iis無法使用,我同事的也是,也不知道是不是跟在網域中有關係,因為我用虛擬機的繁體系統win2003 R2版iis能够正常使用,不過曾经那台電腦也是在網域 ...

  3. Codeforces 39E What Has Dirichlet Got to Do with That? 游戏+内存搜索

    主题链接:点击打开链接 意甲冠军: 特定 a一箱 b球 不变n (球和箱子都不尽相同,样的物品) 设 way = 把b个球放到a个箱子中的方法数, 若way >= n则游戏结束 有2个人玩游戏. ...

  4. 让VC2012生成的程序支持XP系统(QT的DLL都是支持XP的,只与EXE有关)

    如果用的编译器是VC2012以上,那么默认生成出的程序是不能运行在XP系统上的.所以需要修改链接参数 我们要做的是修改qmake.conf文件中的参数,文件路径根据开发环境不同而不同下面以5.1.1 ...

  5. VS2013中安装配置和使用Boost库

    源地址:http://www.itnose.net/detail/6077953.html 时间:2014.07.24 地点:基地 ---------------------------------- ...

  6. 调用一个系统命令,并读取它的输出值(使用QProcess.readAll)

    下面我们再看一个更复杂的例子,调用一个系统命令,这里我使用的是 Windows,因此需要调用 dir:如果你是在 Linux 进行编译,就需要改成 ls 了. mainwindow.h #ifndef ...

  7. RotateDisp – 一键旋转显示画面 - 小众软件

    RotateDisp – 一键旋转显示画面 - 小众软件 RotateDisp – 一键旋转显示画面

  8. hdu 1530 Maximum Clique

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1530 题目分类:最大团问题 DP + DFS 代码: #include<bits/stdc++. ...

  9. Delphi对WM_NCHITTEST消息的处理

    前提:WM_NCHITTEST是很重要的,只要鼠标在活动,Windows无时无刻在发这个消息进行探测. ------------------------------------------------ ...

  10. TStack,TQueue,TObjectList,TObjectStack等等

    TStack,TQueue,TObjectList,TObjectStack等等,都在Contnrs.pas单元里,需要手动添加. 不同于TList类,TObjectList对象将销毁任何从列表中删除 ...