vim /usr/local/nagios/etc/objects/localhost.cfg        
define host {
        host_name           shenmeh         用户名别忘记加到define contactgroup{ members 里
        alias                        test
        address                  server ip
        check_command       check-host-alive          主机状态
        notification_options    d,u,r
        check_interval      1
        max_check_attempts      2
        contact_groups      admins
        notification_interval   10
        notification_period     24x7
}

define service {
        host_name           shenmeh
        service_description     tcp
        check_period        24x7
        normal_check_interval   2
        retry_check_interval    1
        max_check_attempts      5
        notification_period     24x7
        notification_options    w,u,c,r
        check_command       check-tcp!tcp_server_ip!80
}

define service {
        host_name          shenmeh
        service_description     udp
        check_period        24x7
        normal_check_interval   2
        retry_check_interval    1
        max_check_attempts      5
        notification_period     24x7
        notification_options    w,u,c,r
        check_command       check-udp!udp_server_ip!53
}

save&exit

vim /usr/local/nagios/etc/objects/commands.cfg      


define command{
        command_name    check-tcp
        command_line    $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$
}

define command{
        command_name    check-udp
        command_line    $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$
}

save&exit

都是默认的,命令可以自定义  

check_tcp --help

heck-tcp -H host -p port [-w  <warning time>] [ -c <critical time>] [-s <send string>]
 

check_udp --help

check-udp -H host -p port [-w  <warning time>] [ -c <critical time>] [-s <send string>]