check_tcp:监控TCP服务端口

用法: check-tcp -H host -p port [-w  <warning time>] [ -c <critical time>] [-s <send string>]

check_tcp -H 192.168.1.2 -p 80 检测主机的http服务

check_udp:监控UDP服务端口

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

check_udp -H 192.168.1.2 -p 53 检测主机的dns服务

 以上2条命令的用法已经说明下面说下在nagios中的用法

在nagios中先定义主机在定义服务,之后定义命令,简单举例

vim /usr/local/nagios/etc/objects/localhost.cfg       
define host {
        host_name           joker
        alias                      test
        address             192.168.18.65
        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           joker
        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!80
}

define service {
        host_name           joker
        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!53
}

vim /usr/local/nagios/etc/objects/commands.cfg       
define command{
        command_name    check-tcp
        command_line    $USER1$/check_tcp -H $HOSTADDRESS$ -p $ARG1$
}

vim /usr/local/nagios/etc/objects/commands.cfg       
define command{
        command_name    check-udp
        command_line    $USER1$/check_udp -H $HOSTADDRESS$ -p $ARG1$
}