diff --git a/doc/7-icinga-template-library.md b/doc/7-icinga-template-library.md index cb1e3cafa..cddc31bb4 100644 --- a/doc/7-icinga-template-library.md +++ b/doc/7-icinga-template-library.md @@ -424,6 +424,8 @@ http_extendedperfdata | **Optional.** Print additional perfdata. Defaults to http_onredirect | **Optional.** How to handle redirect pages. Possible values: "ok" (default), "warning", "critical", "follow", "sticky" (like follow but stick to address), "stickyport" (like sticky but also to port) http_pagesize | **Optional.** Minimum page size required:Maximum page size required. http_timeout | **Optional.** Seconds before connection times out. +http_ipv4 | **Optional.** Use IPv4 only. +http_ipv6 | **Optional.** Use IPv6 only. ### icmp @@ -516,8 +518,8 @@ nrpe_no_ssl | **Optional.** Whether to disable SSL or not. Defaults to `fals nrpe_timeout_unknown | **Optional.** Whether to set timeouts to unknown instead of critical state. Defaults to `false`. nrpe_timeout | **Optional.** The timeout in seconds. nrpe_arguments | **Optional.** Arguments that should be passed to the command. Multiple arguments must be defined as array. -nrpe_ipv4 | **Optional.** Use IPv4 only. -nrpe_ipv6 | **Optional.** Use IPv6 only. +nrpe_ipv4 | **Optional.** Use IPv4 only. +nrpe_ipv6 | **Optional.** Use IPv6 only. ### nscp @@ -874,6 +876,8 @@ tcp_ssl | **Optional.** Use SSL for the connection. Defaults to false. tcp_wtime | **Optional.** Response time to result in warning status (seconds). tcp_ctime | **Optional.** Response time to result in critical status (seconds). tcp_timeout | **Optional.** Seconds before connection times out. Defaults to 10. +tcp_ipv4 | **Optional.** Use IPv4 only. +tcp_ipv6 | **Optional.** Use IPv6 only. ### udp @@ -889,6 +893,8 @@ udp_port | **Required.** The port that should be checked. udp_send | **Required.** The payload to send in the UDP datagram. udp_expect | **Required.** The payload to expect in the response datagram. udp_quit | **Optional.** The payload to send to 'close' the session. +udp_ipv4 | **Optional.** Use IPv4 only. +udp_ipv6 | **Optional.** Use IPv6 only. ### ups diff --git a/itl/command-plugins.conf b/itl/command-plugins.conf index 88b8d6244..8d640a4d4 100644 --- a/itl/command-plugins.conf +++ b/itl/command-plugins.conf @@ -22,12 +22,15 @@ template CheckCommand "ipv4-or-ipv6" { var addr_v4 = macro("$address$") var addr_v6 = macro("$address6$") - if (addr_v4) { + if (addr_v4 && !macro("$check_ipv6$") || macro("$check_ipv4$")) { return addr_v4 } else { return addr_v6 } }} + + vars.check_ipv4 = false + vars.check_ipv6 = false } template CheckCommand "ping-common" { @@ -243,6 +246,14 @@ object CheckCommand "tcp" { value = "$tcp_timeout$" description = "Seconds before connection times out. Defaults to 10." } + "-4" = { + set_if = "$tcp_ipv4$" + description = "Use IPv4 only" + } + "-6" = { + set_if = "$tcp_ipv6$" + description = "Use IPv6 only" + } } vars.tcp_address = "$check_address$" @@ -250,6 +261,8 @@ object CheckCommand "tcp" { vars.tcp_refuse = "crit" vars.tcp_mismatch = "warn" vars.tcp_timeout = 10 + vars.check_ipv4 = "$tcp_ipv4$" + vars.check_ipv6 = "$tcp_ipv6$" } object CheckCommand "ssl" { @@ -289,9 +302,19 @@ object CheckCommand "udp" { required = true } "-q" = "$udp_quit$" + "-4" = { + set_if = "$udp_ipv4$" + description = "Use IPv4 only" + } + "-6" = { + set_if = "$udp_ipv6$" + description = "Use IPv6 only" + } } vars.udp_address = "$check_address$" + vars.check_ipv4 = "$udp_ipv4$" + vars.check_ipv6 = "$udp_ipv6$" } object CheckCommand "http" { @@ -404,6 +427,14 @@ object CheckCommand "http" { value = "$http_timeout$" description = "Seconds before connection times out" } + "-4" = { + set_if = "$http_ipv4$" + description = "Use IPv4 only" + } + "-6" = { + set_if = "$http_ipv6$" + description = "Use IPv6 only" + } } vars.http_address = "$check_address$" @@ -411,6 +442,8 @@ object CheckCommand "http" { vars.http_sni = false vars.http_linespan = false vars.http_invertregex = false + vars.check_ipv4 = "$http_ipv4$" + vars.check_ipv6 = "$http_ipv6$" } object CheckCommand "ftp" { @@ -1382,17 +1415,19 @@ object CheckCommand "nrpe" { } "-4" = { set_if = "$nrpe_ipv4$" - description = "Use ipv4 only" + description = "Use IPv4 only" } "-6" = { set_if = "$nrpe_ipv6$" - description = "Use ipv6 only" + description = "Use IPv6 only" } } vars.nrpe_address = "$check_address$" vars.nrpe_no_ssl = false vars.nrpe_timeout_unknown = false + vars.check_ipv4 = "$nrpe_ipv4$" + vars.check_ipv6 = "$nrpe_ipv6$" timeout = 5m }