mirror of
https://github.com/Icinga/icinga2.git
synced 2026-04-06 01:28:15 -04:00
So that other components can use it without having to import any Icinga DB related header files, but only the base library.
46 lines
1.4 KiB
C++
46 lines
1.4 KiB
C++
// SPDX-FileCopyrightText: 2012 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include "base/application.hpp"
|
|
#include "base/scriptglobal.hpp"
|
|
|
|
using namespace icinga;
|
|
|
|
AtomicOrLocked<String> Application::m_EnvironmentId;
|
|
|
|
String Application::GetAppEnvironment()
|
|
{
|
|
Value defaultValue = Empty;
|
|
return ScriptGlobal::Get("Environment", &defaultValue);
|
|
}
|
|
|
|
void Application::SetAppEnvironment(const String& name)
|
|
{
|
|
ScriptGlobal::Set("Environment", name);
|
|
}
|
|
|
|
/**
|
|
* Get the cluster environment ID set by IcingaDB.
|
|
*
|
|
* This method returns the cluster environment ID generated by the IcingaDB component (if enabled).
|
|
* The environment ID is a unique identifier used to distinguish between different Icinga 2 clusters
|
|
* in a multi-cluster setup. It is typically set by IcingaDB when it starts up and can be used by other
|
|
* components (e.g., for telemetry) to correlate data across clusters. If IcingaDB is not enabled or has
|
|
* not yet set the environment ID, this method will return an empty string.
|
|
*
|
|
* @return The cluster environment ID set by IcingaDB, or an empty string if not set.
|
|
*/
|
|
String Application::GetEnvironmentId()
|
|
{
|
|
return m_EnvironmentId.load();
|
|
}
|
|
|
|
/**
|
|
* Set the cluster environment ID.
|
|
*
|
|
* @param envID The cluster environment ID to set, typically generated by IcingaDB.
|
|
*/
|
|
void Application::SetEnvironmentId(const String& envID)
|
|
{
|
|
m_EnvironmentId.store(envID);
|
|
}
|