diff --git a/lib/compat/compatlogger.cpp b/lib/compat/compatlogger.cpp index aa3646091..fa8b0ea0b 100644 --- a/lib/compat/compatlogger.cpp +++ b/lib/compat/compatlogger.cpp @@ -37,6 +37,14 @@ void CompatLogger::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&) status->Set("compatlogger", new Dictionary(std::move(nodes))); } +void CompatLogger::OnAllConfigLoaded() +{ + ObjectImpl::OnAllConfigLoaded(); + + Log(LogWarning, "CompatLogger") + << "This feature is DEPRECATED and will be removed in v2.18."; +} + /** * @threadsafety Always. */ @@ -47,9 +55,6 @@ void CompatLogger::Start(bool runtimeCreated) Log(LogInformation, "CompatLogger") << "'" << GetName() << "' started."; - Log(LogWarning, "CompatLogger") - << "This feature is DEPRECATED and may be removed in future releases. Check the roadmap at https://github.com/Icinga/icinga2/milestones"; - Checkable::OnNewCheckResult.connect([this](const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const MessageOrigin::Ptr&) { CheckResultHandler(checkable, cr); }); diff --git a/lib/compat/compatlogger.hpp b/lib/compat/compatlogger.hpp index 3535bb083..e218d4015 100644 --- a/lib/compat/compatlogger.hpp +++ b/lib/compat/compatlogger.hpp @@ -28,6 +28,8 @@ public: void ValidateRotationMethod(const Lazy& lvalue, const ValidationUtils& utils) override; protected: + void OnAllConfigLoaded() override; + void Start(bool runtimeCreated) override; void Stop(bool runtimeRemoved) override; diff --git a/lib/compat/externalcommandlistener.cpp b/lib/compat/externalcommandlistener.cpp index 069df2b5d..2343a488c 100644 --- a/lib/compat/externalcommandlistener.cpp +++ b/lib/compat/externalcommandlistener.cpp @@ -27,6 +27,14 @@ void ExternalCommandListener::StatsFunc(const Dictionary::Ptr& status, const Arr status->Set("externalcommandlistener", new Dictionary(std::move(nodes))); } +void ExternalCommandListener::OnAllConfigLoaded() +{ + ObjectImpl::OnAllConfigLoaded(); + + Log(LogWarning, "ExternalCommandListener") + << "This feature is DEPRECATED and will be removed in v2.18."; +} + /** * Starts the component. */ @@ -37,8 +45,6 @@ void ExternalCommandListener::Start(bool runtimeCreated) Log(LogInformation, "ExternalCommandListener") << "'" << GetName() << "' started."; - Log(LogWarning, "ExternalCommandListener") - << "This feature is DEPRECATED and may be removed in future releases. Check the roadmap at https://github.com/Icinga/icinga2/milestones"; #ifndef _WIN32 String path = GetCommandPath(); m_CommandThread = std::thread([this, path]() { CommandPipeThread(path); }); diff --git a/lib/compat/externalcommandlistener.hpp b/lib/compat/externalcommandlistener.hpp index b7ac6c85c..8d0222b9d 100644 --- a/lib/compat/externalcommandlistener.hpp +++ b/lib/compat/externalcommandlistener.hpp @@ -27,6 +27,8 @@ public: static void StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata); protected: + void OnAllConfigLoaded() override; + void Start(bool runtimeCreated) override; void Stop(bool runtimeRemoved) override; diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 4c8fd6c5a..eda2009ca 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -918,6 +918,17 @@ ExpressionResult ApplyExpression::DoEvaluate(ScriptFrame& frame, DebugHint*) con ExpressionResult NamespaceExpression::DoEvaluate(ScriptFrame&, DebugHint*) const { + DebugInfo adjustedDI = m_DebugInfo; + adjustedDI.LastLine = adjustedDI.FirstLine; + adjustedDI.LastColumn = 0; + + std::ostringstream oss; + ShowCodeLocation(oss, adjustedDI, false); + + Log(LogWarning, "config") + << "User-defined namespaces are deprecated and will be removed in v2.18:\n" + << oss.str(); + Namespace::Ptr ns = new Namespace(true); ScriptFrame innerFrame(true, ns); diff --git a/lib/db_ido_mysql/idomysqlconnection.cpp b/lib/db_ido_mysql/idomysqlconnection.cpp index decda26b8..126c8de17 100644 --- a/lib/db_ido_mysql/idomysqlconnection.cpp +++ b/lib/db_ido_mysql/idomysqlconnection.cpp @@ -47,6 +47,14 @@ void IdoMysqlConnection::OnConfigLoaded() std::swap(m_Library, shimLibrary); } +void IdoMysqlConnection::OnAllConfigLoaded() +{ + ObjectImpl::OnAllConfigLoaded(); + + Log(LogWarning, "IdoMysqlConnection") + << "This feature is DEPRECATED and will be removed in v2.18."; +} + void IdoMysqlConnection::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata) { DictionaryData nodes; diff --git a/lib/db_ido_mysql/idomysqlconnection.hpp b/lib/db_ido_mysql/idomysqlconnection.hpp index a81e664e1..c84626427 100644 --- a/lib/db_ido_mysql/idomysqlconnection.hpp +++ b/lib/db_ido_mysql/idomysqlconnection.hpp @@ -45,6 +45,8 @@ public: protected: void OnConfigLoaded() override; + void OnAllConfigLoaded() override; + void Resume() override; void Pause() override; diff --git a/lib/db_ido_pgsql/idopgsqlconnection.cpp b/lib/db_ido_pgsql/idopgsqlconnection.cpp index 87112113f..845745e1a 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.cpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.cpp @@ -55,6 +55,14 @@ void IdoPgsqlConnection::OnConfigLoaded() std::swap(m_Library, shimLibrary); } +void IdoPgsqlConnection::OnAllConfigLoaded() +{ + ObjectImpl::OnAllConfigLoaded(); + + Log(LogWarning, "IdoPgsqlConnection") + << "This feature is DEPRECATED and will be removed in v2.18."; +} + void IdoPgsqlConnection::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata) { DictionaryData nodes; diff --git a/lib/db_ido_pgsql/idopgsqlconnection.hpp b/lib/db_ido_pgsql/idopgsqlconnection.hpp index 4e3251cff..f67d62b87 100644 --- a/lib/db_ido_pgsql/idopgsqlconnection.hpp +++ b/lib/db_ido_pgsql/idopgsqlconnection.hpp @@ -38,6 +38,7 @@ public: protected: void OnConfigLoaded() override; + void OnAllConfigLoaded() override; void Resume() override; void Pause() override; diff --git a/lib/icinga/checkable.cpp b/lib/icinga/checkable.cpp index a53ab6d13..f5509500e 100644 --- a/lib/icinga/checkable.cpp +++ b/lib/icinga/checkable.cpp @@ -9,6 +9,7 @@ #include "base/utility.hpp" #include "base/exception.hpp" #include "base/timer.hpp" +#include #include using namespace icinga; @@ -16,6 +17,23 @@ using namespace icinga; REGISTER_TYPE(Checkable); INITIALIZE_ONCE(&Checkable::StaticInitialize); +static constexpr std::array l_DeprecatedCheckCommands{ + "disk-windows", + "load-windows", + "memory-windows", + "network-windows", + "perfmon-windows", + "ping-windows", + "ping4-windows", + "ping6-windows", + "procs-windows", + "service-windows", + "swap-windows", + "update-windows", + "uptime-windows", + "users-windows", +}; + const std::map Checkable::m_FlappingStateFilterMap ({ {"OK", FlappingStateFilterOk}, {"Warning", FlappingStateFilterWarning}, @@ -60,6 +78,21 @@ void Checkable::OnAllConfigLoaded() { ObjectImpl::OnAllConfigLoaded(); + const auto it = boost::range::find(l_DeprecatedCheckCommands, GetCheckCommandRaw()); + if (it != l_DeprecatedCheckCommands.end()) { + static std::mutex warnedSetMutex; + static std::unordered_set alreadyWarned; + + std::unique_lock lock{warnedSetMutex}; + auto [_, inserted] = alreadyWarned.emplace(*it); + lock.unlock(); + if (inserted) { + Log(LogWarning, "Checkable") + << "CheckCommand '" << GetCheckCommandRaw() << "' used by '" << GetName() << "' (" << GetDebugInfo() + << ") is DEPRECATED and will be removed in v2.18. Further uses of this check command won't be logged."; + } + } + Endpoint::Ptr endpoint = GetCommandEndpoint(); if (endpoint) { diff --git a/lib/livestatus/livestatuslistener.cpp b/lib/livestatus/livestatuslistener.cpp index 2bd7c2668..85d928af3 100644 --- a/lib/livestatus/livestatuslistener.cpp +++ b/lib/livestatus/livestatuslistener.cpp @@ -42,6 +42,14 @@ void LivestatusListener::StatsFunc(const Dictionary::Ptr& status, const Array::P status->Set("livestatuslistener", new Dictionary(std::move(nodes))); } +void LivestatusListener::OnAllConfigLoaded() +{ + ObjectImpl::OnAllConfigLoaded(); + + Log(LogWarning, "LivestatusListener") + << "This feature is DEPRECATED and will be removed in v2.18."; +} + /** * Starts the component. */ diff --git a/lib/livestatus/livestatuslistener.hpp b/lib/livestatus/livestatuslistener.hpp index 6673c09a8..1371a3956 100644 --- a/lib/livestatus/livestatuslistener.hpp +++ b/lib/livestatus/livestatuslistener.hpp @@ -33,6 +33,8 @@ public: void ValidateSocketType(const Lazy& lvalue, const ValidationUtils& utils) override; protected: + void OnAllConfigLoaded() override; + void Start(bool runtimeCreated) override; void Stop(bool runtimeRemoved) override; diff --git a/lib/perfdata/elasticsearchwriter.cpp b/lib/perfdata/elasticsearchwriter.cpp index 044656966..9f5108ddd 100644 --- a/lib/perfdata/elasticsearchwriter.cpp +++ b/lib/perfdata/elasticsearchwriter.cpp @@ -43,6 +43,14 @@ void ElasticsearchWriter::OnConfigLoaded() } } +void ElasticsearchWriter::OnAllConfigLoaded() +{ + ObjectImpl::OnAllConfigLoaded(); + + Log(LogWarning, "ElasticsearchWriter") + << "This feature is DEPRECATED and will be removed in v2.18."; +} + void ElasticsearchWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata) { DictionaryData nodes; diff --git a/lib/perfdata/elasticsearchwriter.hpp b/lib/perfdata/elasticsearchwriter.hpp index e83f9c935..e9998d2bf 100644 --- a/lib/perfdata/elasticsearchwriter.hpp +++ b/lib/perfdata/elasticsearchwriter.hpp @@ -28,6 +28,7 @@ public: protected: void OnConfigLoaded() override; + void OnAllConfigLoaded() override; void Start(bool runtimeCreated) override; void Resume() override; void Pause() override;