前一段时间在Cu论坛发现一个提问,问题是nagios关于检测主机http服务的.原帖地址http://bbs.chinaunix.net /forum.php?mod=viewthread&tid=4079340&page=1#pid23860101.楼主刚开始想实 现的是检测主机的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 <vhost> | -I <IP-address> [-u <uri>] [-p <port>]
  • [-w <warn time>] [-c <critical time>] [-t <timeout>] [-L] [-a auth]
  • [-b proxy_auth] [-f <ok|warning|critcal|follow|sticky|stickyport>]
  • [-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 <version>] [--sni] [-C <warn_age>[,<crit_age>]]
  • [-T <content-type>] [-j method]
  • 2.自定义一个command,名字随便起,我这里是check_http_u,当然了,我写的简单,你也可以加-w和-c等参数

    点击(此处)折叠或打开

  • define command{
  •         command_name check_http_u
  •         command_line $USER1$/check_http -I $HOSTADDRESS$ -u $ARG1$
  •         }
  • 3.给已经定义过的主机添加一个自定义服务,我这里写成URL1,你可以根据需要修改成其他的.

    点击(此处)折叠或打开

  • 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;
  • }
  • 4. 重启nagios服务,重启没有错误的话,浏览器访问你的nagios服务,过一段时间,就可以看到检测的结果了.
    【转】nagios使用带url的check_http检测主机

     

    转自:blog.chinaunix.net/uid-1730385-id-3683735.html

    相关文章:

    • 2021-10-06
    • 2021-05-09
    • 2021-05-16
    • 2021-11-06
    • 2021-07-04
    • 2021-04-05
    • 2022-12-23
    • 2021-05-17
    猜你喜欢
    • 2022-12-23
    • 2021-08-13
    • 2021-11-21
    • 2022-12-23
    • 2021-06-23
    • 2021-05-16
    • 2021-10-10
    相关资源
    相似解决方案