From b672c28888875c377bed3364ee4f7dc7c923cb1a Mon Sep 17 00:00:00 2001 From: Sukhwinder Dhillon <54990055+sukhwinder33445@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:53:05 +0200 Subject: [PATCH] ProcessCommand: Fix false positive condition for `ServiceNode` (#445) fixes #440 --- application/clicommands/ProcessCommand.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/clicommands/ProcessCommand.php b/application/clicommands/ProcessCommand.php index 018c1e36..2090b635 100644 --- a/application/clicommands/ProcessCommand.php +++ b/application/clicommands/ProcessCommand.php @@ -11,6 +11,7 @@ use Icinga\Module\Businessprocess\HostNode; use Icinga\Module\Businessprocess\Node; use Icinga\Module\Businessprocess\ProvidedHook\Icingadb\IcingadbSupport; +use Icinga\Module\Businessprocess\ServiceNode; use Icinga\Module\Businessprocess\State\IcingaDbState; use Icinga\Module\Businessprocess\State\MonitoringState; use Icinga\Module\Businessprocess\Storage\LegacyStorage; @@ -192,14 +193,15 @@ protected function renderProblemTree($tree, $useColors = false, $depth = 0, BpNo $node = $subtree['node']; $state = $parent !== null ? $parent->getChildState($node) : $node->getState(); + $colors = []; if ($node instanceof HostNode) { $colors = $this->hostColors[$state]; - } else { + } elseif ($node instanceof ServiceNode) { $colors = $this->serviceColors[$state]; } $state = sprintf('[%s]', $node->getStateName($state)); - if ($useColors) { + if ($useColors && ! empty($colors)) { $state = $this->screen->colorize($state, $colors[0], $colors[1]); }