Nagios监控Linux服务器(2)

二、服务器端
1、安装所需的软件(nagios、nagios-plugins、nrpe)下载后源码包安装,不赘述
wget
wget
wget
安装完成后配置一下报警的邮箱
# grep email /usr/local/nagios/etc/objects/contacts.cfg
        email                           minyongtao@innofidei.com        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
2、配置
#在commands.cfg中定义nrpe这个外部构件
#vim /usr/local/nagios/etc/nagios.cfg,打开下面这一行
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
#vim /usr/local/nagios/etc/objects/commands.cfg,增加如下一行
check nrpe
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
3、#配置要监控的linux主机
#cd /usr/local/nagios/etc/objects
#mv localhost.cfg rhel5.cfg
更改如下
注意下面定义的check名字要与linux客户端/usr/local/nagios/etc/nrpe.cfg文件中的名字一致
#cat  rhel5.cfg
# Define a host for the local machine
define host{
        use                     linux-server
        host_name               rhel5
        alias                   rhel5
        address                 172.16.17.220
        }

# SERVICE DEFINITIONS

# Define a service to "ping" the local machine

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       rhel5
        service_description             PING
        check_command                   check_nrpe!check_ping
        }


# Define a service to check the disk space of the root partition
# on the local machine.  Warning if < 20% free, critical if
# < 10% free space on partition.

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       rhel5
        service_description             Root Partition
        check_command                   check_nrpe!check_disk
        }

# Define a service to check the number of currently logged in
# users on the local machine.  Warning if > 20 users, critical
# if > 50 users.

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       rhel5
        service_description             Current Users
        check_command                   check_nrpe!check_users
        }


# Define a service to check the number of currently running procs
# on the local machine.  Warning if > 250 processes, critical if
# > 400 users.

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       rhel5
        service_description             Total Processes
        check_command                   check_nrpe!check_total_procs
        }

# Define a service to check the load on the local machine.

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       rhel5
        service_description             Current Load
        check_command                   check_nrpe!check_load
        }

# Define a service to check the swap usage the local machine.
# Critical if less than 10% of swap is free, warning if less than 20% is free

define service{
        use                             generic-service         ; Name of service template to use
        host_name                       rhel5
        service_description             Swap Usage
        check_command                   check_nrpe!check_swap
        }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/2cc7714ae75e894b0b4989490933ec71.html