前一段时间在Cu论坛发现一个提问,问题是nagios关于检测主机http服务的.原帖地址楼主刚开始想实现的是检测主机的url是否正常,后来有回复用自定义脚本的.经过搜索,发现nagios自带的check_http命令可以使用-u url的方式来检测url的.经过试验,确实是可行的,发帖纪录下.
1.先运行check_http命令看下是否支持-u参数,注意返回的显示里面有没有
点击(此处)折叠或打开
- /usr/local/nagios/libexec/check_http
- check_http: Could not parse arguments
- Usage:
-
check_http -H
| -I [-u ] [-p] -
[-w
] [-c ] [-t ] [-L] [-a auth] -
[-b proxy_auth] [-f
] -
[-e
] [-s string] [-l] [-r | -R ] -
[-P string] [-m
: ] [-4|-6] [-N] [-M ] -
[-A string] [-k string] [-S
] [--sni] [-C [, ]] -
[-T
] [-j method]
点击(此处)折叠或打开
-
define command{
-
command_name check_http_u
-
command_line $USER1$/check_http -I $HOSTADDRESS$ -u $ARG1$
- }
点击(此处)折叠或打开
-
define service{
-
use local-service ; Name of service template to use
-
host_name xxx ;前面定义好的主机名
-
service_description URL1 ;
-
check_command check_http_u!'/path/index.html' ;
-
notifications_enabled 1;
- }