nagios利用NRPE监控CPU、负载、磁盘IO

来源:互联网 发布:通甲优博 知乎 编辑:程序博客网 时间:2024/05/17 04:14


1.在监控机上安装NRPE
tar -zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
 
2.在被监控机上安装nagios插件和NRPE
(1).先增加nagios用户:
useradd nagios

 

(2.)安装nagios插件:
tar -zxvf nagios-plugins-1.4.14.tar.gz
cd nagios-plugins-1.4.14
./configure --prefix=/usr/local/nagios
make
make install

 

(3).安装nrpe:
tar -zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure --prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd    nrpe安装为xinetd服务

 

(4).编辑nrpe配置文件,增加监控机地址:
#vi /etc/xinetd.d/nrpe
only_from  = 127.0.0.1 10.1.1.14

 

(5).修改services文件,增加端口
#vi /etc/services
nrpe            5666/tcp                        #NRPE

 

(6).重启xinetd服务
service xinetd restart

 

(7).查看服务是否启动
#/usr/local/nagios/libexec/check_nrpe -H localhost
NRPE v2.12
如果出现Connection refused by host 需要安装yum intall openssl*
至此被监控机上的操作就结束了,如果有需要增加监控项,需修改/etc/xinetd.d/nrpe文件。
 
3.修改监控机上commands.cfg文件,增加check_nrpe的定义:
define command{
        command_name    check_nrpe
        command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
        }

 

4.在监控机上测试与被监控机的通讯是否正常:
[root@test1 objects]# /usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
OK - load average: 0.05, 0.06, 0.00|load1=0.050;15.000;30.000;0; load5=0.060;10.000;25.000;0; load15=0.000;5.000;20.000;0;
能够正常获取信息。

 


vim /usr/local/nagios/etc/nrpe.cfg

 

修改 allowed_hosts=127.0.0.1,10.1.1.14(监控机)

 

增加
command[check_sda2]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /dev/sda2  --意思是监控第二个分区

 

command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%   -监控内存

 


修改监控机的services.cfg

 

增加需要监控的服务
5.修改服务配置文件:
增加:
define service {
host_name  1.1.1.1
max_check_attempts          5
check_period            24x7
notification_interval       10
normal_check_interval       1
retry_check_interval        1
service_description checkdisk2
check_command check_nrpe!check_sda2             ###########监控第二个硬盘
notification_period    24x7
notification_options    w,u,c,r
contact_groups        tomasgroup
                       }

 


define service {
host_name  1.1.1.1
max_check_attempts          5
check_period            24x7
notification_interval       10
normal_check_interval       1
retry_check_interval        1
service_description checkLoad
check_command check_nrpe!check_load            ###########     监控CPU负载
notification_period    24x7
notification_options    w,u,c,r
contact_groups         tomasgroup
                       }


define service {
host_name  1.1.1.1
max_check_attempts          5
check_period            24x7
notification_interval       10
normal_check_interval       1
retry_check_interval        1
service_description checkswap
check_command check_nrpe!check_swap                   监控内存
notification_period    24x7
notification_options    w,u,c,r
contact_groups         tomasgroup      }

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 肩膀抻着了怎么办妙招 右边肩膀抻着了怎么办 胳膊因劳累很痛怎么办 宝宝胳膊摔了疼怎么办 宝宝胳膊抻筋了怎么办 孕妇胳膊筋伤了怎么办 刚进公司就怀孕怎么办 撞到胳膊麻筋了怎么办 腰抻了怎么办多久能好 腰突然抻了一下怎么办 干活抻筋了 很疼怎么办 胳膊抻筋一动就疼怎么办 肩膀受风了很疼怎么办 开空调受风了怎么办 胳膊受风了疼怎么办 孩子胳膊抻筋了怎么办 胳膊被风吹了疼怎么办 月子里胳膊受风怎么办 受风了胳膊酸痛怎么办 胳膊受风了在家怎么办 手臂烧伤手肿了怎么办 胳膊里的筋疼怎么办 3岁胳膊背筋了怎么办 左胳膊筋一直疼怎么办 手臂突然筋扭了怎么办 胳膊扭了肿了怎么办 胖人走路磨大腿怎么办 脖子上长了个淋巴结怎么办 面部危险三角区长痘痘怎么办 儿童脖子上有淋巴结节怎么办 左侧颈根部淋巴结肿大怎么办 人的三角区肿了怎么办 刮三角区肿了怎么办 乳腺增生引起的腋窝淋巴结怎么办 右边脸比左边脸大怎么办 六个月宝宝脖子有点歪怎么办 大人的头偏了怎么办 宝宝脖子睡偏了怎么办 宝宝头歪向左边怎么办 一岁宝宝头歪怎么办 宝宝头往右边歪怎么办