mirror of https://github.com/Icinga/icinga2.git
Merge pull request #6305 from gunnarbeutner/feature/environment-variable
Introduce the 'Environment' variable
This commit is contained in:
commit
7f579db9af
|
@ -400,6 +400,7 @@ BuildCompilerVersion|**Read-only.** The version of the compiler Icinga was built
|
|||
BuildHostName |**Read-only.** The name of the host Icinga was built on, e.g. "acheron".
|
||||
ApplicationVersion |**Read-only.** The application version, e.g. "2.9.0".
|
||||
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".
|
||||
|
||||
|
||||
Advanced runtime constants. Please only use them if advised by support or developers.
|
||||
|
|
|
@ -221,6 +221,8 @@ static int Main()
|
|||
Application::DeclareConcurrency(std::thread::hardware_concurrency());
|
||||
Application::DeclareMaxConcurrentChecks(Application::GetDefaultMaxConcurrentChecks());
|
||||
|
||||
ScriptGlobal::Set("Environment", "production");
|
||||
|
||||
ScriptGlobal::Set("AttachDebugger", false);
|
||||
|
||||
ScriptGlobal::Set("PlatformKernel", Utility::GetPlatformKernel());
|
||||
|
|
|
@ -81,7 +81,8 @@ void IcingaApplication::StatsFunc(const Dictionary::Ptr& status, const Array::Pt
|
|||
{ "enable_perfdata", icingaapplication->GetEnablePerfdata() },
|
||||
{ "pid", Utility::GetPid() },
|
||||
{ "program_start", Application::GetStartTime() },
|
||||
{ "version", Application::GetAppVersion() }
|
||||
{ "version", Application::GetAppVersion() },
|
||||
{ "environment", ScriptGlobal::Get("Environment", &Empty) }
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
|
@ -382,10 +382,16 @@ 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, endpoint->GetName(), RoleClient);
|
||||
NewClientHandler(client, serverName, RoleClient);
|
||||
endpoint->SetConnecting(false);
|
||||
} catch (const std::exception& ex) {
|
||||
endpoint->SetConnecting(false);
|
||||
|
|
Loading…
Reference in New Issue