From 239bbbb117e9974d4da84f18de68c58b58558dd5 Mon Sep 17 00:00:00 2001 From: Daniel Cebrian Date: Mon, 29 Apr 2024 16:31:42 +0200 Subject: [PATCH] #13521 fixed status color widget --- .../lib/Dashboard/Widgets/module_value.php | 31 +++++++------------ 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/module_value.php b/pandora_console/include/lib/Dashboard/Widgets/module_value.php index 87992ab3ba..dde1d93508 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/module_value.php +++ b/pandora_console/include/lib/Dashboard/Widgets/module_value.php @@ -447,25 +447,18 @@ class ModuleValueWidget extends Widget $sizeLabel = (isset($this->values['sizeLabel']) === true) ? $this->values['sizeLabel'] : 40; $sizeValue = (isset($this->values['sizeValue']) === true) ? $this->values['sizeValue'] : 40; - $sql = 'SELECT min_warning, - max_warning, - min_critical, - max_critical, - str_warning, - str_critical - FROM tagente_modulo - WHERE id_agente_modulo = '.(int) $this->values['moduleId']; - $sql_data = db_get_row_sql($sql); - - $last = modules_get_last_value($this->values['moduleId']); - - if (($last >= $sql_data['min_warning']) && ($last < $sql_data['max_warning'])) { - $color = COL_WARNING; - } - - if ($last >= $sql_data['max_warning']) { - $color = COL_CRITICAL; - } + $db_status = modules_get_agentmodule_status($this->values['moduleId']); + $module_value = modules_get_last_value($this->values['moduleId']); + $status = 0; + $title = ''; + modules_get_status($this->values['moduleId'], $db_status, $module_value, $status, $title); + $color = match ($status) { + STATUS_MODULE_NO_DATA => COL_NOTINIT, + STATUS_MODULE_CRITICAL => COL_CRITICAL, + STATUS_MODULE_WARNING => COL_WARNING, + STATUS_MODULE_OK => COL_NORMAL, + STATUS_MODULE_UNKNOWN => COL_UNKNOWN, + }; $uuid = uniqid(); $output .= '
';