Skip to content

Commit

Permalink
Fake data to indicate affected children
Browse files Browse the repository at this point in the history
  • Loading branch information
raviks789 committed Oct 21, 2024
1 parent 061f67a commit c5625e5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
12 changes: 11 additions & 1 deletion library/Icingadb/Common/IcingaRedis.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
$keyMap[$alias] = $column->getStatement() ;
} else {
$keyMap[$alias] = null;
}
}

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
Expand Down
3 changes: 2 additions & 1 deletion library/Icingadb/Model/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;
use ipl\Orm\ResultSet;
use ipl\Sql\Expression;

/**
* Host model.
Expand Down Expand Up @@ -113,7 +114,7 @@ public function getColumns()
'zone_id',
'command_endpoint_name',
'command_endpoint_id',
'affected_children'
'affected_children' => new Expression('200000')
];
}

Expand Down
3 changes: 2 additions & 1 deletion library/Icingadb/Model/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use ipl\Orm\Model;
use ipl\Orm\Relations;
use ipl\Orm\ResultSet;
use ipl\Sql\Expression;

/**
* @property string $id
Expand Down Expand Up @@ -106,7 +107,7 @@ public function getColumns()
'zone_id',
'command_endpoint_name',
'command_endpoint_id',
'affected_children'
'affected_children' => new Expression('10')
];
}

Expand Down
3 changes: 2 additions & 1 deletion library/Icingadb/Model/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use ipl\Orm\Behavior\MillisecondTimestamp;
use ipl\Orm\Behaviors;
use ipl\Orm\Model;
use ipl\Sql\Expression;
use ipl\Web\Widget\Icon;

/**
Expand Down Expand Up @@ -100,7 +101,7 @@ public function getColumns()
'last_state_change',
'next_check',
'next_update',
'affects_children'
'affects_children' => new Expression("'y'")
];
}

Expand Down

0 comments on commit c5625e5

Please sign in to comment.