vim /usr/local/nagios/etc/objects/commands.cfg
2、经过上步还不明白可以查看帮助文件,各个参数的作用
/usr/local/nagios/libexec/check_tcp --help
3、在客户端使用使用该命令测试
[root@zlee libexec]# /usr/local/nagios/libexec/check_tcp -I
TCP OK - 0.000 second response time on port
4、测试成功后增加监控主机的监控服务即可,要写上相应的变量,
5、check_udp用法同check_tcp,仅以check_tcp举例。
vim /usr/local/nagios/etc/objects/commands.cfg
# 'check_tcp' command definition
define command{
command_name check_tcp
command_line $USER1$/check_tcp -I $HOSTADDRESS$ -p
}
define service {
host_name 你监控的主机名
service_description apache
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_http!80
[root@zlee libexec]# service nagios restart
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.