From: Strajan Sebastian Ioan Date: Fri, 29 Sep 2017 15:51:40 +0000 (+0300) Subject: Add support for check_address as default in database CheckCommand objects X-Git-Tag: v2.8.0~35^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=21207724173691e6cfc368f077e633d1adb08f69;p=icinga2 Add support for check_address as default in database CheckCommand objects 1. set the default hostname to the "$check_address$" for multiple CheckCommands 2. add support for "$check_address$" for ping4 and ping6 commands which don't import the ipv4-or-ipv6 template This commit changes the default address for redis, mongodb and elasticsearch to use check_address instead of localhost. Users who might not have set this explicitly in their services should adopt this. Signed-off-by: Michael Friedrich Signed-off-by: Gunnar Beutner --- diff --git a/doc/10-icinga-template-library.md b/doc/10-icinga-template-library.md index b91515c03..a0d8890ee 100644 --- a/doc/10-icinga-template-library.md +++ b/doc/10-icinga-template-library.md @@ -2331,7 +2331,7 @@ Custom attributes passed as [command parameters](03-monitoring-basics.md#command Name | Description ---------------------------------|------------------------------------------------------------------------------------------------------------------------------ -mongodb_host | **Required.** Specifies the hostname or address. +mongodb_host | **Required.** Specifies the hostname or address. Defaults to "$address$" if the host's `address` attribute is set, "$address6$" otherwise. mongodb_port | **Required.** The port mongodb is running on. mongodb_user | **Optional.** The username you want to login as. mongodb_passwd | **Optional.** The password you want to use for that user. @@ -2359,8 +2359,8 @@ Custom attributes passed as [command parameters](03-monitoring-basics.md#command Name | Description -----------------------------|------------------------------------------------------------------------------------------------------- +elasticsearch_host | **Optional.** Hostname or network address to probe. Defaults to "$address$" if the host's `address` attribute is set, "$address6$" otherwise. elasticsearch_failuredomain | **Optional.** A comma-separated list of ElasticSearch attributes that make up your cluster's failure domain. -elasticsearch_host | **Optional.** Hostname or network address to probe. Defaults to 'localhost'. elasticsearch_masternodes | **Optional.** Issue a warning if the number of master-eligible nodes in the cluster drops below this number. By default, do not monitor the number of nodes in the cluster. elasticsearch_port | **Optional.** TCP port to probe. The ElasticSearch API should be listening here. Defaults to 9200. elasticsearch_prefix | **Optional.** Optional prefix (e.g. 'es') for the ElasticSearch API. Defaults to ''. @@ -2377,7 +2377,7 @@ Custom attributes passed as [command parameters](03-monitoring-basics.md#command Name | Description -------------------------|-------------------------------------------------------------------------------------------------------------- -redis_hostname | **Required.** Hostname or IP Address to check. Defaults to "127.0.0.1". +redis_hostname | **Required.** Hostname or IP Address to check. Defaults to "$address$" if the host's `address` attribute is set, "$address6$" otherwise. redis_port | **Optional.** Port number to query. Default to "6379". redis_database | **Optional.** Database name (usually a number) to query, needed for **redis_query**. redis_password | **Optional.** Password for Redis authentication. Safer alternative is to put them in a file and use **redis_credentials**. diff --git a/itl/plugins-contrib.d/databases.conf b/itl/plugins-contrib.d/databases.conf index 5b23b78b5..bb73a93ff 100644 --- a/itl/plugins-contrib.d/databases.conf +++ b/itl/plugins-contrib.d/databases.conf @@ -18,6 +18,8 @@ ******************************************************************************/ object CheckCommand "mssql_health" { + import "ipv4-or-ipv6" + command = [ PluginContribDir + "/check_mssql_health" ] arguments = { @@ -335,6 +337,8 @@ object CheckCommand "mysql_health" { } object CheckCommand "db2_health" { + import "ipv4-or-ipv6" + command = [ PluginContribDir + "/check_db2_health" ] arguments = { @@ -428,6 +432,8 @@ object CheckCommand "db2_health" { } object CheckCommand "oracle_health" { + import "ipv4-or-ipv6" + command = [ PluginContribDir + "/check_oracle_health" ] arguments = { @@ -604,6 +610,8 @@ object CheckCommand "postgres" { } object CheckCommand "mongodb" { + import "ipv4-or-ipv6" + command = [ PluginContribDir + "/check_mongodb.py" ] arguments = { @@ -678,11 +686,14 @@ object CheckCommand "mongodb" { } } + vars.mongodb_address = "$check_address$" vars.mongodb_perfdata = true vars.mongodb_action = "connections" } object CheckCommand "elasticsearch" { + import "ipv4-or-ipv6" + command = [ PluginContribDir + "/check_elasticsearch" ] arguments = { @@ -713,10 +724,13 @@ object CheckCommand "elasticsearch" { } } + vars.elasticsearch_host = "$check_address$" vars.elasticsearch_yellowcritical = false } object CheckCommand "redis" { + import "ipv4-or-ipv6" + command = [ PluginContribDir + "/check_redis.pl" ] arguments = { @@ -805,7 +819,7 @@ object CheckCommand "redis" { } } - vars.redis_hostname = "127.0.0.1" + vars.redis_hostname = "$check_address$" vars.redis_perfparse = false vars.redis_prev_perfdata = false }