From fed5e7d4847ef6f4fcbf9f3c49bc9bb25e0be455 Mon Sep 17 00:00:00 2001 From: raviks789 Date: Fri, 4 Oct 2024 11:43:20 +0200 Subject: [PATCH] Fake data to indicate affected children --- library/Icingadb/Common/IcingaRedis.php | 12 +++++++++++- library/Icingadb/Model/Host.php | 2 +- library/Icingadb/Model/Service.php | 2 +- library/Icingadb/Model/State.php | 2 +- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/library/Icingadb/Common/IcingaRedis.php b/library/Icingadb/Common/IcingaRedis.php index a22a0f03b..b86b5817f 100644 --- a/library/Icingadb/Common/IcingaRedis.php +++ b/library/Icingadb/Common/IcingaRedis.php @@ -8,6 +8,7 @@ use Generator; use Icinga\Application\Config; use Icinga\Application\Logger; +use ipl\Sql\Expression; use Predis\Client as Redis; class IcingaRedis @@ -163,7 +164,16 @@ protected static function fetchState(string $key, array $ids, array $columns): G foreach ($results as $i => $json) { if ($json !== null) { $data = json_decode($json, true); - $keyMap = array_fill_keys($columns, null); + $keyMap = []; + + foreach ($columns as $alias => $column) { + if ($column instanceof Expression) { + $column = $alias; + } + + $keyMap[] = $column; + } + unset($keyMap['is_overdue']); // Is calculated by Icinga DB, not Icinga 2, hence it's never in redis // TODO: Remove once https://github.com/Icinga/icinga2/issues/9427 is fixed diff --git a/library/Icingadb/Model/Host.php b/library/Icingadb/Model/Host.php index 05c35bc07..c42d66ec7 100644 --- a/library/Icingadb/Model/Host.php +++ b/library/Icingadb/Model/Host.php @@ -113,7 +113,7 @@ public function getColumns() 'zone_id', 'command_endpoint_name', 'command_endpoint_id', - 'affected_children' + 'affected_children' => new Expression('200000') ]; } diff --git a/library/Icingadb/Model/Service.php b/library/Icingadb/Model/Service.php index dea47a75d..6cd6791e2 100644 --- a/library/Icingadb/Model/Service.php +++ b/library/Icingadb/Model/Service.php @@ -105,7 +105,7 @@ public function getColumns() 'zone_id', 'command_endpoint_name', 'command_endpoint_id', - 'affected_children' + 'affected_children' => new Expression('10') ]; } diff --git a/library/Icingadb/Model/State.php b/library/Icingadb/Model/State.php index a4556c1d5..abc35d751 100644 --- a/library/Icingadb/Model/State.php +++ b/library/Icingadb/Model/State.php @@ -100,7 +100,7 @@ public function getColumns() 'last_state_change', 'next_check', 'next_update', - 'affects_children' + 'affects_children' => new Expression("'y'") ]; }