我正在尝试使用 icinga2 来确保某些“金丝雀”网页能够正确提供。以下命令在终端中运行良好:
/usr/lib64/nagios/plugins/check_http -f follow -H target -u /tomcat_test
HTTP OK: HTTP/1.1 200 OK - 9381 bytes in 0.446 second response time |time=0.446154s;;;0.000000 size=9381B;;;0`
如果我使用此模式创建自定义规则,则自定义变量在屏幕上是正确的,但检查失败并出现错误
Name or service not known
HTTP CRITICAL - Unable to open TCP socket`
以下投入生产时,出现故障的原因是什么?
object CheckCommand "check_hosted_pages" {
import "migration-check-command"
command = "/usr/lib64/nagios/plugins/check_http -f follow -H $vars.fqdn$ -u $vars.page$"
}
apply Service "check_hosted_pages" for (page in host.vars.WEBPAGES) {
import "generic-service"
display_name = "Web pages"
check_command = "check_hosted_pages"
vars.fqdn = host.name + "." + host.vars.DOMAIN
vars.page = page
}
答案1
经过反复试验后,答案原来是检查命令中的语法问题。
command = "/usr/lib64/nagios/plugins/check_http -f follow -H $vars.fqdn$ -u $vars.page$"
本来应该
command = "/usr/lib64/nagios/plugins/check_http -N -H $fqdn$ -u $page$"