实战Nagios网络监控(2)—— Nagios+Nrpe监控其他主机


需要的包:nagios-plugins-2.1.1.tar.gz 

                  nrpe-2.15.tar.gz

服务器端:server1.example.com        172.25.254.1

新监控端:server2.example.com        172.25.254.2

实验前提:

      /etc/init.d/httpd start

/etc/init.d/nagios start

/etc/init.d/mysqld start##如果启不开的化,cd /var/lib/mysql/,然后,rm -rf mysql.sock再启动

chkconfig httpd on

chkconfig mysqld on

浏览器登陆 172.25.38.6/nagios查看服务状态


1.新监控端配置(server2)

    1.1  .tar zxf nrpe-2.15.tar.gz

       tar zxf nagios-plugins-2.1.1.tar.gz          #nagios 插件安装

       cd nagios-plugins-2.1.1

        yum install gcc -y openssl-devel mysql-devel

         useradd -M -d /usr/local/nagios nagios    ##id号不规定一定是要900,因为服务器上设置的是900,所以认为统一比较好

     1.2 ./configure --with-nagios-user=nagios --with-nagios-group=nagios

        make

        make install 

     1.3   chown nagios.nagios /usr/local/nagios

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

        yum install xinetd

     1.4 cd nrpe-2.15 

           ./configure 

           make all

           make install-plugin

           make install-daemon

           make install-daemon-config

           make install-xinetd

         cd /etc/xinetd.d/

      1.5 vim nrpe

实战Nagios网络监控(2)—— Nagios+Nrpe监控其他主机

#nrpe 服务监听端口

     1.6 vim /etc/services

  加入

实战Nagios网络监控(2)—— Nagios+Nrpe监控其他主机  

    1.7 cd ../etc/

         vim  nrpe.cfg   实战Nagios网络监控(2)—— Nagios+Nrpe监控其他主机

#根分区监测

/etc/init.d/xinetd start


    1.8 cd /usr/local/nagios/libexec/

          scp check_nrpe [email protected]:/usr/local/nagios/libexec/

    

2.服务器端配置(server1)

    2.1  [[email protected] libexec]# ll check_nrpe

 -rwxr-xr-x 1 root root 76769 Jul 23 10:02 check_nrpe

   [[email protected] libexec]# chown nagios:nagios check_nrpe##更改脚本权限为nagios所有

   [[email protected] libexec]# ll check_nrpe

  -rwxr-xr-x 1 nagios nagios 76769 Jul 23 10:02 check_nrpe

    2.2  [[email protected] libexec]# ./check_nrpe -H 172.25.254.2 -c check_disk##执行脚本

  DISK OK - free space: / 5333 MB (83% inode=92%);| /=1086MB;5410;6086;0;6763

           [[email protected] libexec]# ./check_nrpe -H 172.25.254.2 -c check_load##执行脚本

  OK - load average: 0.00, 0.00, 0.00|load1=0.000;15.000;30.000;0;                                                          load5=0.000;10.000;25.000;0; load15=0.000;5.000;20.000;0; 

    2.3  cd /usr/local/nagios/etc/objects/

            vim commands.cfg

*****************************************************************************************

218 #'check_nrpe' command definition

219 define command{

220         command_name    check_nrpe

221         command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

222        

}

****************************************************************************************

    vim services.cfg

*****************************************************************************************************

117 ###########check_nrpe############################

118 define service{

119         use                              local-service      

120         host_name                       server2.example.com

121         service_description                根分区

122         check_command                  check_nrpe!check_disk

123         }

124 

125 

126 define service{

127         use                               local-service 

128         host_name                        server2.example.com

129         service_description                 登录用户数

130         check_command                   check_nrpe!check_users

131         }

*******************************************************************************************

    vim   hosts.cfg

*******************************************************************************************define host{

        use                     linux-server            ; 

        host_name               server2.example.com

        alias                   server2

        address                 172.25.254.2

        icon_image              switch.gif

        statusmap_image         switch.gd2

        2d_coords               400,100

        3d_coords               400,200,100

        }

*******************************************************************************************

    2.4 /etc/init.d/nagios reload


浏览器端刷新访问:


实战Nagios网络监控(2)—— Nagios+Nrpe监控其他主机


本文转自willis_sun 51CTO博客,原文链接:http://blog.51cto.com/willis/1866092,如需转载请自行联系原作者