nagios利用NRPE監控CPU、負載、磁盤IO


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      }


轉自:http://tomas.blog.51cto.com/2660202/477956


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM