【问题标题】:why is checking a URL failing when run through icinga?为什么在通过 icinga 运行时检查 URL 失败?
【发布时间】:2012-08-21 13:25:02
【问题描述】:

我创建了自己的命令来检查特定的 URL

define command{
    command_name    check_url
    command_line    /usr/lib/nagios/plugins/check_http -f follow -H '$HOSTNAME$' -I '$HOSTADDRESS$' -u '$ARG1$'
    }

如果我从命令行运行我的命令,它会起作用:

/usr/lib/nagios/plugins/check_http -f follow -H www.example.com -u http://www.example.com/server-status

HTTP OK: HTTP/1.1 200 OK - 4826 bytes in 0.011 second response time  |time=0.010625s;;;0.000000 size=4826B;;;0

但是当我穿过 Icinga 时,我得到了

HTTP WARNING: HTTP/1.1 404 NOT FOUND - 314 bytes in 0.011 second response time 

【问题讨论】:

    标签: nagios


    【解决方案1】:

    我的猜测是用于 -u 选项的 check_http 插件,您应该提供附加在服务器名称之后的 url,而不是整个 url。 例如。

    /usr/lib/nagios/plugins/check_http -f follow -H www.example.com -u /server-status

    【讨论】:

      【解决方案2】:

      您的手动测试不等同于您的命令定义。

      与 -H/-I 的区别很微妙,但非常重要。

      【讨论】:

        【解决方案3】:

        当我遇到这样的问题时,Icinga 正在抽象它是如何执行命令的,我发现准确地找出 Icinga 正在执行的内容很有帮助。我将按如下方式完成:

        将 check_http 移动到一个临时位置

        # mv /usr/lib/nagios/plugins/check_http /usr/lib/nagios/plugins/check_http_actual
        

        制作一个 Icinga 将调用的 bash 脚本,而不是实际的 check_http 脚本

        # vi /usr/lib/nagios/plugins/check_http
        

        在该文件中,创建这个简单的 bash 脚本,它简单地回显调用它的命令行参数,然后退出:

        #!/bin/bash
        echo $@
        

        当然,让那个 bash 脚本可执行:

        # chmod +x /usr/lib/nagios/plugins/check_http
        

        现在在 Icinga 中,运行 check_http 命令。此时,Icinga Web 界面中显示的返回状态将准确显示 Icinga 如何调用 check_http。看到原始命令,应该很明显 Icinga 做错了什么。一旦你纠正了 Icinga 的错误,你可以简单地将原来的 check_http 脚本移回原处:

        # mv /usr/lib/nagios/plugins/{check_http_actual,check_http}
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-11-13
          • 1970-01-01
          • 2013-02-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多