Icinga2 check_http fails to open socket
I'm attempting to use icinga2 to make sure certain "canary" web pages are being served correctly. The following command works just fine in the terminal:
/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`
If I create a custom rule with this pattern, the custom variables are correct on screen, but the check fails with the error
Name or service not known
HTTP CRITICAL - Unable to open TCP socket`
What's causing the failure when the following is put into production?
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
}
After some trial and error, the answer turned out to be a syntax problem in the check command.
command = "/usr/lib64/nagios/plugins/check_http -f follow -H $vars.fqdn$ -u $vars.page$"
should have been
command = "/usr/lib64/nagios/plugins/check_http -N -H $fqdn$ -u $page$"