From b4e106606835faccdc8101287aaaafffaccb1491 Mon Sep 17 00:00:00 2001 From: Alvar Penning Date: Fri, 11 Oct 2024 17:18:11 +0200 Subject: [PATCH] IcingaDB: Log if both instances are responsible First, this scenario should not happen. However, if it may have occurred due to whatever reasons, Icinga 2 should at least acknowledge it. The current code simply ignores the possibility that invalid data may be available in "icingadb:telemetry:heartbeat". --- lib/icingadb/icingadbchecktask.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/icingadb/icingadbchecktask.cpp b/lib/icingadb/icingadbchecktask.cpp index f7c596457c4..cee93cd3384 100644 --- a/lib/icingadb/icingadbchecktask.cpp +++ b/lib/icingadb/icingadbchecktask.cpp @@ -227,7 +227,9 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR perfdata->Add(new PerfdataValue("icinga2_heartbeat_age", heartbeatLag, false, "seconds", heartbeatLagWarning, Empty, 0)); } - if (weResponsible) { + if (weResponsible && otherResponsible) { + critmsgs << " Both this instance and another instance are responsible!"; + } else if (weResponsible) { idbokmsgs << "\n* Responsible"; } else if (otherResponsible) { idbokmsgs << "\n* Not responsible, but another instance is"; @@ -235,7 +237,7 @@ void IcingadbCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckR critmsgs << " No instance is responsible!"; } - perfdata->Add(new PerfdataValue("icingadb_responsible_instances", int(weResponsible || otherResponsible), false, "", Empty, Empty, 0, 1)); + perfdata->Add(new PerfdataValue("icingadb_responsible_instances", int(weResponsible) + int(otherResponsible), false, "", Empty, Empty, 0, 1)); const auto clockDriftWarning (5); const auto clockDriftCritical (30);