// SPDX-FileCopyrightText: 2012 Icinga GmbH // SPDX-License-Identifier: GPL-2.0-or-later #include "base/application.hpp" #include "base/scriptglobal.hpp" using namespace icinga; AtomicOrLocked 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); }