mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
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".
|
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".
|
ApplicationVersion |**Read-only.** The application version, e.g. "2.9.0".
|
||||||
MaxConcurrentChecks |**Read-write**. The number of max checks run simultaneously. Defaults to 512.
|
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.
|
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::DeclareConcurrency(std::thread::hardware_concurrency());
|
||||||
Application::DeclareMaxConcurrentChecks(Application::GetDefaultMaxConcurrentChecks());
|
Application::DeclareMaxConcurrentChecks(Application::GetDefaultMaxConcurrentChecks());
|
||||||
|
|
||||||
|
ScriptGlobal::Set("Environment", "production");
|
||||||
|
|
||||||
ScriptGlobal::Set("AttachDebugger", false);
|
ScriptGlobal::Set("AttachDebugger", false);
|
||||||
|
|
||||||
ScriptGlobal::Set("PlatformKernel", Utility::GetPlatformKernel());
|
ScriptGlobal::Set("PlatformKernel", Utility::GetPlatformKernel());
|
||||||
|
@ -81,7 +81,8 @@ void IcingaApplication::StatsFunc(const Dictionary::Ptr& status, const Array::Pt
|
|||||||
{ "enable_perfdata", icingaapplication->GetEnablePerfdata() },
|
{ "enable_perfdata", icingaapplication->GetEnablePerfdata() },
|
||||||
{ "pid", Utility::GetPid() },
|
{ "pid", Utility::GetPid() },
|
||||||
{ "program_start", Application::GetStartTime() },
|
{ "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();
|
TcpSocket::Ptr client = new TcpSocket();
|
||||||
|
|
||||||
|
String serverName = endpoint->GetName();
|
||||||
|
|
||||||
|
String env = ScriptGlobal::Get("Environment", &Empty);
|
||||||
|
if (env != "" && env != "production")
|
||||||
|
serverName += ":" + env;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
endpoint->SetConnecting(true);
|
endpoint->SetConnecting(true);
|
||||||
client->Connect(host, port);
|
client->Connect(host, port);
|
||||||
NewClientHandler(client, endpoint->GetName(), RoleClient);
|
NewClientHandler(client, serverName, RoleClient);
|
||||||
endpoint->SetConnecting(false);
|
endpoint->SetConnecting(false);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
endpoint->SetConnecting(false);
|
endpoint->SetConnecting(false);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user