nagios 默认使用是ip方式来监控,问题如果是基于域名的虚拟主机,IP不可访问,只能用域名访问,如何监测?
运行check_http 可以发现-H <vhost> 是使用-H来监控虚拟主机的。
check_http: Could not parse arguments
Usage: check_http -H <vhost> | -I <IP-address> [-u <uri>] [-p <port>]
[-w <warn time>] [-c <critical time>] [-t <timeout>] [-L]
[-a auth] [-f <ok | warn | critcal | follow>] [-e <expect>]
[-s string] [-l] [-r <regex> | -R <case-insensitive regex>] [-P string]
[-m <min_pg_size>:<max_pg_size>] [-4|-6] [-N] [-M <age>] [-A string]
[-k string] [-S] [-C <age>] [-T <content-type>]
如何实现呢: 在nagios的services.cfg 中
原先监控:
define service {
host_name crm.1.2
service_description check tomcat
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups admins
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_http! -u /moncheck.txt -p 80
修改:
check_command check_http! -H xxx.xxx.xxx.com -u /moncheck.txt -p 80 重启即可。
前人栽树,后人乘凉,参考下面文章。
http://www.dbalife.com/archives/137.html