From eb02d9041d32abb76626b85c6893cb76dc40bcfe Mon Sep 17 00:00:00 2001 From: Markus Frosch Date: Thu, 2 Aug 2018 14:09:21 +0200 Subject: [PATCH 1/7] Refactor environment for API connections * Const renamed to `ApiEnvironment` * Handling moved to ApiListener * Now a property of ApiListener --- doc/06-distributed-monitoring.md | 39 ++++++++++++++++++++++++++++++-- doc/09-object-types.md | 1 + doc/17-language-reference.md | 3 +-- icinga-app/icinga.cpp | 2 -- lib/icinga/icingaapplication.cpp | 3 +-- lib/remote/apilistener.cpp | 16 ++++++------- lib/remote/apilistener.ti | 4 ++++ 7 files changed, 52 insertions(+), 16 deletions(-) diff --git a/doc/06-distributed-monitoring.md b/doc/06-distributed-monitoring.md index 985e23fd9..15353de90 100644 --- a/doc/06-distributed-monitoring.md +++ b/doc/06-distributed-monitoring.md @@ -116,8 +116,7 @@ you still need a [Host](09-object-types.md#objecttype-host) object. In case you are using the CLI commands later, you don't have to write this configuration from scratch in a text editor. -The [ApiListener](09-object-types.md#objecttype-apilistener) -object is used to load the SSL certificates and specify restrictions, e.g. +The [ApiListener] object is used to load the SSL certificates and specify restrictions, e.g. for accepting configuration commands. It is also used for the [Icinga 2 REST API](12-icinga2-api.md#icinga2-api) which shares @@ -2793,3 +2792,39 @@ Add the global zone `global-templates` in case it did not exist. global = true } EOF + +## Using Multiple Environments + +In some cases it might be useful to run multiple Icinga instance on the same host. Two potential scenarios include: + +* running different versions of the same monitoring configuration (e.g. production and testing) +* running disparate sets of checks for entirely unrelated monitoring environments (e.g. infrastructure and applications) + +Configuration is controlled via constants and attributes of the [ApiListener]. + +Constant | Attribute +---------------|---------- +ApiEnvironment | environment +ApiBindHost | bind_host +ApiBindPort | bind_port + +In any case the constant is default value for the attribute, so that a direct configuration in the [ApiListener] object +has more precedence. The constants have been created to allow the values to be set from the command line on startup. + +When Icinga establishes a TLS connection to another cluster instance it automatically uses the [SNI extension] +to signal which endpoint it is attempting to connect to. On its own this can already be used to position multiple +Icinga instances behind a load balancer. + +SNI example: `icinga2-client1.localdomain` + +However, if the environment is configured, Icinga will append the environment name to the SNI hostname like this: + +SNI example with environment: `icinga2-client1.localdomain:production` + +Middleware like loadbalancers or TLS proxies can read the SNI header and route the connection to the appropriate target. +I.e., it uses a single externally-visible TCP port (usually 5665) and forwards connections to one or more Icinga +instances which are bound to a local TCP port. It does so by inspecting the environment name that is sent as part of the +SNI extension. + +[ApiListener]: 09-object-types.md#objecttype-apilistener +[SNI Extension]: https://en.wikipedia.org/wiki/Server_Name_Indication diff --git a/doc/09-object-types.md b/doc/09-object-types.md index 904e31b23..06584ef1d 100644 --- a/doc/09-object-types.md +++ b/doc/09-object-types.md @@ -67,6 +67,7 @@ Configuration Attributes: access\_control\_allow\_credentials | Boolean | **Deprecated.** Indicates whether or not the actual request can be made using credentials. Defaults to `true`. [(MDN docs)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Allow-Credentials) access\_control\_allow\_headers | String | **Deprecated.** Used in response to a preflight request to indicate which HTTP headers can be used when making the actual request. Defaults to `Authorization`. [(MDN docs)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Allow-Headers) access\_control\_allow\_methods | String | **Deprecated.** Used in response to a preflight request to indicate which HTTP methods can be used when making the actual request. Defaults to `GET, POST, PUT, DELETE`. [(MDN docs)](https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Access-Control-Allow-Methods) + environment | String | **Optional.** Used as suffix in TLS SNI extension name; default from constant `ApiEnvironment`, which is empty. The attributes `access_control_allow_credentials`, `access_control_allow_headers` and `access_control_allow_methods` are controlled by Icinga 2 and are not changeable by config any more. diff --git a/doc/17-language-reference.md b/doc/17-language-reference.md index de94ba4e8..9dbb0de03 100644 --- a/doc/17-language-reference.md +++ b/doc/17-language-reference.md @@ -410,7 +410,7 @@ NodeName |**Read-write.** Contains the cluster node name. Set to the RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig. RunAsGroup |**Read-write.** Defines the group the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig. MaxConcurrentChecks |**Read-write.** The number of max checks run simultaneously. Defaults to `512`. -Environment |**Read-write.** The name of the Icinga environment. Included in the SNI host name when making outbound connections. Defaults to `production`. +ApiEnvironment |**Read-write**. The name of the Icinga environment for ApiListener. Included in the SNI host name when making outbound connections. Defaults to `production`. ApiBindHost |**Read-write.** Overrides the default value for the ApiListener `bind_host` attribute. Not set by default. ApiBindPort |**Read-write.** Overrides the default value for the ApiListener `bind_port` attribute. Not set by default. @@ -454,7 +454,6 @@ SysconfDir |**Read-only.** Contains the path of the sysconf directory. LocalStateDir |**Read-only.** Contains the path of the local state directory. Defaults to `PrefixDir + "/var"`. RunDir |**Read-only.** Contains the path of the run directory. Defaults to `LocalStateDir + "/run"`. - Advanced runtime constants. Please only use them if advised by support or developers. Variable | Description diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 3849ca658..26ed4cf69 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -297,8 +297,6 @@ static int Main() Application::DeclareConst("Concurrency", std::thread::hardware_concurrency()); Application::DeclareConst("MaxConcurrentChecks", Application::GetDefaultMaxConcurrentChecks()); - ScriptGlobal::Set("Environment", "production"); - ScriptGlobal::Set("AttachDebugger", false); ScriptGlobal::Set("PlatformKernel", Utility::GetPlatformKernel()); diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index 6ac00aa60..b792cdfe7 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -81,8 +81,7 @@ void IcingaApplication::StatsFunc(const Dictionary::Ptr& status, const Array::Pt { "enable_perfdata", icingaapplication->GetEnablePerfdata() }, { "pid", Utility::GetPid() }, { "program_start", Application::GetStartTime() }, - { "version", Application::GetAppVersion() }, - { "environment", ScriptGlobal::Get("Environment", &Empty) } + { "version", Application::GetAppVersion() } })); } diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 428fb2df7..5e0d2a1bf 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -388,16 +388,10 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint) TcpSocket::Ptr client = new TcpSocket(); - String serverName = endpoint->GetName(); - - String env = ScriptGlobal::Get("Environment", &Empty); - if (env != "" && env != "production") - serverName += ":" + env; - try { endpoint->SetConnecting(true); client->Connect(host, port); - NewClientHandler(client, serverName, RoleClient); + NewClientHandler(client, endpoint->GetName(), RoleClient); endpoint->SetConnecting(false); } catch (const std::exception& ex) { endpoint->SetConnecting(false); @@ -447,10 +441,16 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri TlsStream::Ptr tlsStream; + String environmentName = GetEnvironment(); + String serverName = hostname; + + if (!environmentName.IsEmpty() && environmentName != "") + serverName += ":" + environmentName; + { ObjectLock olock(this); try { - tlsStream = new TlsStream(client, hostname, role, m_SSLContext); + tlsStream = new TlsStream(client, serverName, role, m_SSLContext); } catch (const std::exception&) { Log(LogCritical, "ApiListener") << "Cannot create TLS stream from client connection (" << conninfo << ")"; diff --git a/lib/remote/apilistener.ti b/lib/remote/apilistener.ti index 04e483270..239ae9ce3 100644 --- a/lib/remote/apilistener.ti +++ b/lib/remote/apilistener.ti @@ -48,6 +48,10 @@ class ApiListener : ConfigObject default {{{ return Application::GetConst("ApiBindPort", "5665"); }}} }; + [config] String environment { + default {{{ return Application::GetConst("ApiEnvironment"); }}} + }; + [config] bool accept_config; [config] bool accept_commands; From cd94b7731e110fbbadd5b861063866ea495c4063 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 9 Aug 2018 12:22:55 +0200 Subject: [PATCH 2/7] Update doc anchors --- doc/06-distributed-monitoring.md | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/doc/06-distributed-monitoring.md b/doc/06-distributed-monitoring.md index 15353de90..04d091716 100644 --- a/doc/06-distributed-monitoring.md +++ b/doc/06-distributed-monitoring.md @@ -116,7 +116,8 @@ you still need a [Host](09-object-types.md#objecttype-host) object. In case you are using the CLI commands later, you don't have to write this configuration from scratch in a text editor. -The [ApiListener] object is used to load the SSL certificates and specify restrictions, e.g. +The [ApiListener](09-object-types.md#objecttype-apilistener) object is +used to load the TLS certificates and specify restrictions, e.g. for accepting configuration commands. It is also used for the [Icinga 2 REST API](12-icinga2-api.md#icinga2-api) which shares @@ -2795,12 +2796,14 @@ Add the global zone `global-templates` in case it did not exist. ## Using Multiple Environments -In some cases it might be useful to run multiple Icinga instance on the same host. Two potential scenarios include: +In some cases it can be desired to run multiple Icinga instances on the same host. +Two potential scenarios include: -* running different versions of the same monitoring configuration (e.g. production and testing) -* running disparate sets of checks for entirely unrelated monitoring environments (e.g. infrastructure and applications) +* Different versions of the same monitoring configuration (e.g. production and testing) +* Disparate sets of checks for entirely unrelated monitoring environments (e.g. infrastructure and applications) -Configuration is controlled via constants and attributes of the [ApiListener]. +The configuration is done with global constants and attributes of the +[ApiListener](09-object-types.md#objecttype-apilistener) object. Constant | Attribute ---------------|---------- @@ -2808,10 +2811,10 @@ ApiEnvironment | environment ApiBindHost | bind_host ApiBindPort | bind_port -In any case the constant is default value for the attribute, so that a direct configuration in the [ApiListener] object -has more precedence. The constants have been created to allow the values to be set from the command line on startup. +In any case the constant is default value for the attribute and the direct configuration in the ApiListener object +has more precedence. The constants have been added to allow the values being set from the CLI on startup. -When Icinga establishes a TLS connection to another cluster instance it automatically uses the [SNI extension] +When Icinga establishes a TLS connection to another cluster instance it automatically uses the [SNI extension](https://en.wikipedia.org/wiki/Server_Name_Indication) to signal which endpoint it is attempting to connect to. On its own this can already be used to position multiple Icinga instances behind a load balancer. @@ -2825,6 +2828,3 @@ Middleware like loadbalancers or TLS proxies can read the SNI header and route t I.e., it uses a single externally-visible TCP port (usually 5665) and forwards connections to one or more Icinga instances which are bound to a local TCP port. It does so by inspecting the environment name that is sent as part of the SNI extension. - -[ApiListener]: 09-object-types.md#objecttype-apilistener -[SNI Extension]: https://en.wikipedia.org/wiki/Server_Name_Indication From b350512b118882a499bfa839868eaebf594aa233 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Thu, 9 Aug 2018 12:41:22 +0200 Subject: [PATCH 3/7] Rename to Environment constant --- doc/17-language-reference.md | 2 +- lib/remote/apilistener.ti | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/17-language-reference.md b/doc/17-language-reference.md index 9dbb0de03..12a8dd908 100644 --- a/doc/17-language-reference.md +++ b/doc/17-language-reference.md @@ -407,10 +407,10 @@ Constant | Description --------------------|------------------- Vars |**Read-write.** Contains a dictionary with global custom attributes. Not set by default. NodeName |**Read-write.** Contains the cluster node name. Set to the local hostname by default. +Environment |**Read-write**. The name of the Icinga environment. Included in the SNI host name when making outbound connections. Defaults to `production`. RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig. RunAsGroup |**Read-write.** Defines the group the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig. MaxConcurrentChecks |**Read-write.** The number of max checks run simultaneously. Defaults to `512`. -ApiEnvironment |**Read-write**. The name of the Icinga environment for ApiListener. Included in the SNI host name when making outbound connections. Defaults to `production`. ApiBindHost |**Read-write.** Overrides the default value for the ApiListener `bind_host` attribute. Not set by default. ApiBindPort |**Read-write.** Overrides the default value for the ApiListener `bind_port` attribute. Not set by default. diff --git a/lib/remote/apilistener.ti b/lib/remote/apilistener.ti index 239ae9ce3..05a330990 100644 --- a/lib/remote/apilistener.ti +++ b/lib/remote/apilistener.ti @@ -49,7 +49,7 @@ class ApiListener : ConfigObject }; [config] String environment { - default {{{ return Application::GetConst("ApiEnvironment"); }}} + default {{{ return Application::GetConst("Environment"); }}} }; [config] bool accept_config; From caefa58cf6e8da09ac9a2695db9e80d12ddd37b3 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 10 Aug 2018 10:39:17 +0200 Subject: [PATCH 4/7] Mkclass: Only render setter if not declared pure virtual --- tools/mkclass/classcompiler.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/mkclass/classcompiler.cpp b/tools/mkclass/classcompiler.cpp index 374c54d1c..0e1ee8954 100644 --- a/tools/mkclass/classcompiler.cpp +++ b/tools/mkclass/classcompiler.cpp @@ -568,7 +568,8 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&) << "{" << std::endl; for (const Field& field : klass.Fields) { - m_Impl << "\t" << "Set" << field.GetFriendlyName() << "(" << "GetDefault" << field.GetFriendlyName() << "(), true);" << std::endl; + if (!field.PureSetAccessor) + m_Impl << "\t" << "Set" << field.GetFriendlyName() << "(" << "GetDefault" << field.GetFriendlyName() << "(), true);" << std::endl; } m_Impl << "}" << std::endl << std::endl; From 97513965e6b025aac527ba8be3be5daaff66c9be Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 10 Aug 2018 10:15:41 +0200 Subject: [PATCH 5/7] Introduce IcingaApplication#environment Precedence as follows: - DEnvironment=... - const Environment = ... - object IcingaApplication "app" { environment = "..." } The wrapped script constant handling is required since we cannot directly link from libremote (SNI handling) to libicinga where the object resides. Instead we'll use the Application class helpers for hiding the ScriptGlobal calls. --- lib/base/CMakeLists.txt | 2 +- lib/base/application-environment.cpp | 34 ++++++++++++++++++++++++++++ lib/base/application.hpp | 3 +++ lib/icinga/icingaapplication.cpp | 10 ++++++++ lib/icinga/icingaapplication.hpp | 3 +++ lib/icinga/icingaapplication.ti | 6 +++++ lib/remote/apilistener.cpp | 5 ++-- lib/remote/apilistener.ti | 4 ---- 8 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 lib/base/application-environment.cpp diff --git a/lib/base/CMakeLists.txt b/lib/base/CMakeLists.txt index c16cda028..e784a3957 100644 --- a/lib/base/CMakeLists.txt +++ b/lib/base/CMakeLists.txt @@ -27,7 +27,7 @@ mkclass_target(sysloglogger.ti sysloglogger-ti.cpp sysloglogger-ti.hpp) set(base_SOURCES i2-base.hpp - application.cpp application.hpp application-ti.hpp application-version.cpp + application.cpp application.hpp application-ti.hpp application-version.cpp application-environment.cpp array.cpp array.hpp array-script.cpp base64.cpp base64.hpp boolean.cpp boolean.hpp boolean-script.cpp diff --git a/lib/base/application-environment.cpp b/lib/base/application-environment.cpp new file mode 100644 index 000000000..a70ea886f --- /dev/null +++ b/lib/base/application-environment.cpp @@ -0,0 +1,34 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) * + * * + * This program is free software; you can redistribute it and/or * + * modify it under the terms of the GNU General Public License * + * as published by the Free Software Foundation; either version 2 * + * of the License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the Free Software Foundation * + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * + ******************************************************************************/ + +#include "base/application.hpp" +#include "base/scriptglobal.hpp" + +using namespace icinga; + +String Application::GetAppEnvironment() +{ + Value defaultValue = Empty; + return ScriptGlobal::Get("Environment", &defaultValue); +} + +void Application::SetAppEnvironment(const String& name) +{ + ScriptGlobal::Set("Environment", name); +} diff --git a/lib/base/application.hpp b/lib/base/application.hpp index dbb14c38d..88fc51ab6 100644 --- a/lib/base/application.hpp +++ b/lib/base/application.hpp @@ -107,6 +107,9 @@ public: static String GetAppVersion(); static String GetAppSpecVersion(); + static String GetAppEnvironment(); + static void SetAppEnvironment(const String& name); + static double GetStartTime(); static void SetStartTime(double ts); diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index b792cdfe7..20a800514 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -293,6 +293,16 @@ String IcingaApplication::GetNodeName() const return ScriptGlobal::Get("NodeName"); } +String IcingaApplication::GetEnvironment() const +{ + return Application::GetAppEnvironment(); +} + +void IcingaApplication::SetEnvironment(const String& value, bool suppress_events, const Value& cookie) +{ + Application::SetAppEnvironment(value); +} + void IcingaApplication::ValidateVars(const Lazy& lvalue, const ValidationUtils& utils) { MacroProcessor::ValidateCustomVars(this, lvalue()); diff --git a/lib/icinga/icingaapplication.hpp b/lib/icinga/icingaapplication.hpp index eac7f5903..ba8b77cf3 100644 --- a/lib/icinga/icingaapplication.hpp +++ b/lib/icinga/icingaapplication.hpp @@ -50,6 +50,9 @@ public: String GetNodeName() const; + String GetEnvironment() const override; + void SetEnvironment(const String& value, bool suppress_events = false, const Value& cookie = Empty) override; + void ValidateVars(const Lazy& lvalue, const ValidationUtils& utils) override; private: diff --git a/lib/icinga/icingaapplication.ti b/lib/icinga/icingaapplication.ti index 61d4ecd4c..b9f0381b3 100644 --- a/lib/icinga/icingaapplication.ti +++ b/lib/icinga/icingaapplication.ti @@ -26,6 +26,12 @@ namespace icinga class IcingaApplication : Application { + [config, no_storage, virtual] String environment { + get; + set; + default {{{ return Application::GetAppEnvironment(); }}} + }; + [config] bool enable_notifications { default {{{ return true; }}} }; diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 5e0d2a1bf..8c0abf570 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -441,10 +441,11 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri TlsStream::Ptr tlsStream; - String environmentName = GetEnvironment(); + String environmentName = Application::GetAppEnvironment(); + String serverName = hostname; - if (!environmentName.IsEmpty() && environmentName != "") + if (!environmentName.IsEmpty()) serverName += ":" + environmentName; { diff --git a/lib/remote/apilistener.ti b/lib/remote/apilistener.ti index 05a330990..04e483270 100644 --- a/lib/remote/apilistener.ti +++ b/lib/remote/apilistener.ti @@ -48,10 +48,6 @@ class ApiListener : ConfigObject default {{{ return Application::GetConst("ApiBindPort", "5665"); }}} }; - [config] String environment { - default {{{ return Application::GetConst("Environment"); }}} - }; - [config] bool accept_config; [config] bool accept_commands; From 02009525a18d4b2a03c9906d5c57a88d390c0ef5 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 10 Aug 2018 12:53:06 +0200 Subject: [PATCH 6/7] Update documentation and add upgrading notes --- doc/06-distributed-monitoring.md | 16 +++++++--------- doc/09-object-types.md | 1 + doc/16-upgrading-icinga-2.md | 1 + doc/17-language-reference.md | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/doc/06-distributed-monitoring.md b/doc/06-distributed-monitoring.md index 04d091716..8795335ed 100644 --- a/doc/06-distributed-monitoring.md +++ b/doc/06-distributed-monitoring.md @@ -2802,17 +2802,15 @@ Two potential scenarios include: * Different versions of the same monitoring configuration (e.g. production and testing) * Disparate sets of checks for entirely unrelated monitoring environments (e.g. infrastructure and applications) -The configuration is done with global constants and attributes of the +The configuration is done with the global constants `ApiBindHost` and `ApiBindPort` +or the `bind_host` and `bind_port` attributes of the [ApiListener](09-object-types.md#objecttype-apilistener) object. -Constant | Attribute ----------------|---------- -ApiEnvironment | environment -ApiBindHost | bind_host -ApiBindPort | bind_port +The environment must be set with the global constant `Environment` or as object attribute +of the [IcingaApplication](#objecttype-icingaapplication) object. -In any case the constant is default value for the attribute and the direct configuration in the ApiListener object -has more precedence. The constants have been added to allow the values being set from the CLI on startup. +In any case the constant is default value for the attribute and the direct configuration in the objects +have more precedence. The constants have been added to allow the values being set from the CLI on startup. When Icinga establishes a TLS connection to another cluster instance it automatically uses the [SNI extension](https://en.wikipedia.org/wiki/Server_Name_Indication) to signal which endpoint it is attempting to connect to. On its own this can already be used to position multiple @@ -2820,7 +2818,7 @@ Icinga instances behind a load balancer. SNI example: `icinga2-client1.localdomain` -However, if the environment is configured, Icinga will append the environment name to the SNI hostname like this: +However, if the environment is configured to `production`, Icinga appends the environment name to the SNI hostname like this: SNI example with environment: `icinga2-client1.localdomain:production` diff --git a/doc/09-object-types.md b/doc/09-object-types.md index 06584ef1d..d04f78156 100644 --- a/doc/09-object-types.md +++ b/doc/09-object-types.md @@ -817,6 +817,7 @@ Configuration Attributes: enable\_service\_checks | Boolean | **Optional.** Whether active service checks are globally enabled. Defaults to true. enable\_perfdata | Boolean | **Optional.** Whether performance data processing is globally enabled. Defaults to true. vars | Dictionary | **Optional.** A dictionary containing custom attributes that are available globally. + environment | String | **Optional.** Specify the Icinga environment. This overrides the `Environment` constant specified in the configuration or on the CLI with `--define`. Defaults to empty. ## IdoMySqlConnection diff --git a/doc/16-upgrading-icinga-2.md b/doc/16-upgrading-icinga-2.md index cce8cd916..4e4db7c7f 100644 --- a/doc/16-upgrading-icinga-2.md +++ b/doc/16-upgrading-icinga-2.md @@ -41,6 +41,7 @@ has been removed and this setting has no effect. New [Icinga constants](17-language-reference.md#icinga-constants) have been added in this release. +* `Environment` for specifying the Icinga environment. Defaults to not set. * `ApiBindHost` and `ApiBindPort` to allow overriding the default ApiListener values. This will be used for an Icinga addon only. ## Upgrading to v2.9 diff --git a/doc/17-language-reference.md b/doc/17-language-reference.md index 12a8dd908..f7fae4695 100644 --- a/doc/17-language-reference.md +++ b/doc/17-language-reference.md @@ -407,7 +407,7 @@ Constant | Description --------------------|------------------- Vars |**Read-write.** Contains a dictionary with global custom attributes. Not set by default. NodeName |**Read-write.** Contains the cluster node name. Set to the local hostname by default. -Environment |**Read-write**. The name of the Icinga environment. Included in the SNI host name when making outbound connections. Defaults to `production`. +Environment |**Read-write.** The name of the Icinga environment. Included in the SNI host name for outbound connections. Not set by default. RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig. RunAsGroup |**Read-write.** Defines the group the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig. MaxConcurrentChecks |**Read-write.** The number of max checks run simultaneously. Defaults to `512`. From 2ee6dfaf93205aa94b2cd38ae21f444f4b28d304 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Fri, 10 Aug 2018 13:01:53 +0200 Subject: [PATCH 7/7] Re-add environment to IcingaApplication feature stats --- lib/icinga/icingaapplication.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index 20a800514..4db75d852 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -79,6 +79,7 @@ void IcingaApplication::StatsFunc(const Dictionary::Ptr& status, const Array::Pt { "enable_host_checks", icingaapplication->GetEnableHostChecks() }, { "enable_service_checks", icingaapplication->GetEnableServiceChecks() }, { "enable_perfdata", icingaapplication->GetEnablePerfdata() }, + { "environment", icingaapplication->GetEnvironment() }, { "pid", Utility::GetPid() }, { "program_start", Application::GetStartTime() }, { "version", Application::GetAppVersion() }