diff --git a/components/db_ido_mysql/idomysqlconnection.cpp b/components/db_ido_mysql/idomysqlconnection.cpp index 0ae4db4c5..2c9eeb11f 100644 --- a/components/db_ido_mysql/idomysqlconnection.cpp +++ b/components/db_ido_mysql/idomysqlconnection.cpp @@ -62,6 +62,9 @@ Value IdoMysqlConnection::StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& pe void IdoMysqlConnection::Resume(void) { + if (!IsPaused()) + return; + DbConnection::Resume(); m_Connected = false; @@ -84,6 +87,11 @@ void IdoMysqlConnection::Resume(void) void IdoMysqlConnection::Pause(void) { + if (!GetEnableHa()) { + Log(LogInformation, "IdoMysqlConnection", "HA functionality disabled. Won't pause IDO connection: " + GetName()); + return; + } + m_ReconnectTimer.reset(); DbConnection::Pause(); diff --git a/components/db_ido_pgsql/idopgsqlconnection.cpp b/components/db_ido_pgsql/idopgsqlconnection.cpp index adf4ef3eb..ff7fc49cc 100644 --- a/components/db_ido_pgsql/idopgsqlconnection.cpp +++ b/components/db_ido_pgsql/idopgsqlconnection.cpp @@ -64,6 +64,9 @@ Value IdoPgsqlConnection::StatsFunc(Dictionary::Ptr& status, Dictionary::Ptr& pe void IdoPgsqlConnection::Resume(void) { + if (!IsPaused()) + return; + DbConnection::Resume(); m_Connection = NULL; @@ -86,6 +89,11 @@ void IdoPgsqlConnection::Resume(void) void IdoPgsqlConnection::Pause(void) { + if (!GetEnableHa()) { + Log(LogInformation, "IdoMysqlConnection", "HA functionality disabled. Won't pause IDO connection: " + GetName()); + return; + } + m_ReconnectTimer.reset(); DbConnection::Pause(); diff --git a/lib/db_ido/db_ido-type.conf b/lib/db_ido/db_ido-type.conf index b85608b75..780e52c69 100644 --- a/lib/db_ido/db_ido-type.conf +++ b/lib/db_ido/db_ido-type.conf @@ -38,5 +38,7 @@ %attribute %number "systemcommands_age", }, - %attribute %number "categories" + %attribute %number "categories", + + %attribute %number "enable_ha", } diff --git a/lib/db_ido/dbconnection.cpp b/lib/db_ido/dbconnection.cpp index 0678e75b0..5fa4db7be 100644 --- a/lib/db_ido/dbconnection.cpp +++ b/lib/db_ido/dbconnection.cpp @@ -108,6 +108,7 @@ void DbConnection::ProgramStatusHandler(void) query2.Fields->Set("status_update_time", DbValue::FromTimestamp(Utility::GetTime())); query2.Fields->Set("program_start_time", DbValue::FromTimestamp(Application::GetStartTime())); query2.Fields->Set("is_currently_running", 1); + query2.Fields->Set("endpoint_name", IcingaApplication::GetInstance()->GetNodeName()); query2.Fields->Set("process_id", Utility::GetPid()); query2.Fields->Set("daemon_mode", 1); query2.Fields->Set("last_command_check", DbValue::FromTimestamp(Utility::GetTime())); @@ -358,7 +359,7 @@ void DbConnection::UpdateAllObjects(void) void DbConnection::PrepareDatabase(void) { - /* + /* * only clear tables on reconnect which * cannot be updated by their existing ids * for details check https://dev.icinga.org/issues/5565 diff --git a/lib/db_ido/dbconnection.ti b/lib/db_ido/dbconnection.ti index d71af8517..da9f0c327 100644 --- a/lib/db_ido/dbconnection.ti +++ b/lib/db_ido/dbconnection.ti @@ -21,6 +21,10 @@ abstract class DbConnection : DynamicObject DbCatLog | DbCatNotification | DbCatProgramStatus | DbCatRetention | DbCatStateHistory; }}} }; + + [config] bool enable_ha { + default {{{ return true; }}} + }; }; }