nagios监控国外主机超时

项目上在国外(新加坡)有个主机,由于和谐墙的原因,用check_ping对其进行监控频繁超时,报错,收了一大堆通知邮件。没办法只能把检测超时时间设置大一点。

1.编辑新的检测命令

vim /etc/nagios/objects/commands.cfg  #增加如下内容-p 1 -t 200,意思是发送一个包,超时时间设置为200s

# 'check-mwa-alive' command definition
define command{
        command_name    check-mwa-alive
        command_line    $USER1$/check_ping -H $HOSTADDRESS$ -w 3000.0,90% -c 5000.0,100% -p 1 -t 200
        }

2.增加检测主机是否存活模板

vim /etc/nagios/objects/templates.cfg

define host{
        name                            mwa-server    ; The name of this host template
        use                             generic-host    ; This template inherits other values from the generic-host template
        check_period                    24x7            ; By default, Linux hosts are checked round the clock
        check_interval                  30               ; Actively check the host every 30 minutes ;每隔30分钟检查一次
        retry_interval                  1               ; Schedule host check retries at 1 minute intervals ;重试间隔
        max_check_attempts              5               ; Check each Linux host 10 times (max);重试次数
        check_command                   check-mwa-alive ; Default command to check Linux hosts;检测命令,第一步定义的

#       notification_period             workhours       ; Linux admins hate to be woken up, so we only notify during the day
                                                        ; Note that the notification_period variable is being overridden from
        notification_period             24x7            ; the value that is inherited from the generic-host template!
        notification_interval           60              ; Resend notifications every 2 hours
        notification_options            d,u,r           ; Only send notifications for specific host states
        contact_groups                  users           ; Notifications get sent to the admins by default
        register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        }

3.编辑检测项目

vim /etc/nagios/server/mwa.cfg

define host{
        use                     mwa-server            ; Name of host template to use ;用第二部定义的模板:mwa-server
        host_name               mwa
        alias                   mwa
        address                 128.199.93.212
        }

4.检查配置文件是否正确

nagios -v /etc/nagios/nagios.cfg

Checking services...
    Checked 54 services.
Checking hosts...
Warning: Host 'mwa' has no services associated with it!
    Checked 7 hosts.
Checking host groups...
    Checked 1 host groups.
Checking service groups...
    Checked 0 service groups.
Checking contacts...
    Checked 6 contacts.
Checking contact groups...
    Checked 2 contact groups.
Checking service escalations...
    Checked 0 service escalations.
Checking service dependencies...
    Checked 0 service dependencies.
Checking host escalations...
    Checked 0 host escalations.
Checking host dependencies...
    Checked 0 host dependencies.
Checking commands...
    Checked 26 commands.
Checking time periods...
    Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 1
Total Errors:   0

5.重启nagios服务

service nagios restart

你可能感兴趣的:(nagios)