From f9be5f81d686b1934058bbdab318632c10f85a32 Mon Sep 17 00:00:00 2001 From: Ravi Kumar Kempapura Srinivasa Date: Mon, 25 May 2020 10:32:11 +0200 Subject: [PATCH] Change state calculation in IcingaDbState Since we are fetching the values directly using assembleSelect instead of using ORM, 'last_state_change', 'in_downtime' and 'ack' have different values compared to monitored nodes other than IcingaDb MySQL backend. This is addresses in this commit. --- library/Businessprocess/State/IcingaDbState.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/Businessprocess/State/IcingaDbState.php b/library/Businessprocess/State/IcingaDbState.php index 09af2ce..018ded4 100644 --- a/library/Businessprocess/State/IcingaDbState.php +++ b/library/Businessprocess/State/IcingaDbState.php @@ -148,18 +148,20 @@ class IcingaDbState extends IcingaDbBackend return; } + // Since we are fetching the values directly using assembleSelect instead of using ORM, + // the following changes for 'last_state_change', 'in_downtime' and 'ack' is required $node = $config->getNode($key); if ($row->state !== null) { $node->setState($row->state)->setMissing(false); } if ($row->last_state_change !== null) { - $node->setLastStateChange($row->last_state_change); + $node->setLastStateChange($row->last_state_change/1000); } - if ((int) $row->in_downtime === 1) { + if ($row->in_downtime === 'y') { $node->setDowntime(true); } - if ((int) $row->ack === 1) { + if ($row->ack !== 'n') { $node->setAck(true); }