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.
This commit is contained in:
Ravi Kumar Kempapura Srinivasa 2020-05-25 10:32:11 +02:00 committed by raviks789
parent d1526a36cb
commit f9be5f81d6

View file

@ -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);
}