我有在VirtualBox的Ubuntu 14.04.3 icinga 2.3.11。 我试图监控“https”端口443例如“ https://mail.google.com ”here.Below是我的代码段从默认的host.conf文件
object Host "mailserver-01" { import "generic-host" address = "74.125.136.17" /* ip for mail.google.com */ vars.os = "Linux" vars.http_vhosts["http"] = { http_uri = "/" } vars.http_ssl = "1" vars.http_warn_time = "5" vars.http_critical_time = "10" vars.notification["mail"] = { groups = [ "icingaadmins" ] } }
以下是默认的services.conf文件的代码片段
apply Service "httpS" { import "generic-service" check_command = "http" assign where host.name == "mailserver-01" }
虽然icingaweb2仪表板显示OK /绿色,我不知道这是否是正确的方式
您的主机将自定义属性“http_vhosts”定义为字典,但从未使用过(不适用于定义迭代该字典和生长服务对象的规则)。
相反,服务应用规则(没有for循环)只是应用服务“httpS”。 偶然的主机自定义属性“http_ssl”被设置 – 它应该阅读true为布尔,而不是数字作为string(总是如此)。
你可能想要检查多个URI,而不仅仅是/。
我的build议(2解决scheme):
1)修复您的服务应用规则,并从主机对象定义中删除http_ *自定义属性。 请将它们添加到服务应用规则中:
apply Service "httpS" { import "generic-service" check_command = "http" vars.http_uri = "/" vars.http_ssl = true assign where host.name == "mailserver-01" }
您可以在文档中find所有用作http CheckCommand命令参数的自定义属性: http ://docs.icea.org/icinga2/latest/doc/module/icinga2/chapter/plugin-check-commands#plugin-check- 命令HTTP
2)改为使用服务申请规则,并在主机上定义的http_vhosts字典上循环。
vars.http_vhosts["https /"] = { http_ssl = true http_uri = "/" }
请注意这里的命名:“https /”将是生成的服务名称。 http_ssl和http_uri与http CheckCommand所需的自定义属性完全相同。
申请规则内发生的魔术:字典密钥将是服务名称。 字典值是一个嵌套字典,包含http_uri和http_ssl作为键。 在这个叫做“config”的例子中。 该configuration字典具有与“vars”属性完全相同的结构,这就是为什么我们可以将其添加到服务申请定义。
apply Service for (servicename => config in host.vars.http_vhosts) { import "generic-service" check_command = "http" vars += config }
使用icinga2守护进程-Cvalidationconfiguration,然后查看生成的服务对象,以查看哪些自定义属性生成(icinga2对象列表)。
一件好事 – 具有定义的http_vhosts定制属性的所有主机将生成这些服务对象,不需要extea“assign where”expression式(可能相当于在例外情况下添加忽略)。 使用正确的策略,您只需申请一次规则,并且仅在将来添加具有匹配自定义属性字典的新主机:-)
http://docs.icinga.org/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#using-apply-for
尽pipe解决scheme2)需要关于icinga 2configuration语言及其关键字,值types和魔术的高级知识。 但是我们认为这样的方法和最佳实践有助于通过采用和更改文件来减less长期维护。
您也可以进一步使用基于主机名称的不同阈值的if-else条件。 或者使用函数来定义基于时间段的dynamic阈值。
我GOOGLE了,并findhttp命令
/usr/share/icinga2/include/command-plugins.conf
在这个例子中,我试图监视https://mail.google.com下面是/etc/icinga2/conf.d/hosts.conf
object Host "www.google.com" { address = "74.125.136.84" check_command = "http" vars.http_vhost = "mail.google.com" vars.http_ssl = "1" }
在这里它在icingaweb2仪表板上看起来像什么
例题
object Host "secure.example.com" { address = "14.28.83.22" check_command = "http" vars.http_vhosts["secure.example.com"] = { http_uri = "/merchant/login.aspx" } vars.notification["mail"] = { groups = [ "icingaadmins" ] } vars.http_ssl="1" }