From 461f4f13cb070cfed12010a4b7c43c9547068f57 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Wed, 5 Oct 2022 17:06:55 +0200 Subject: [PATCH 1/6] new widget grouped meter graphs pandora_enterprise#8620 --- .../include/lib/Dashboard/Widget.php | 1 + .../Dashboard/Widgets/GroupedMeterGraphs.php | 883 ++++++++++++++++++ pandora_console/include/styles/dashboards.css | 122 +++ 3 files changed, 1006 insertions(+) create mode 100644 pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php diff --git a/pandora_console/include/lib/Dashboard/Widget.php b/pandora_console/include/lib/Dashboard/Widget.php index cbb4a7ccfe..de5727a56f 100644 --- a/pandora_console/include/lib/Dashboard/Widget.php +++ b/pandora_console/include/lib/Dashboard/Widget.php @@ -416,6 +416,7 @@ class Widget $className .= '\OsQuickReportWidget'; break; + case 'GroupedMeterGraphs': case 'ColorModuleTabs': case 'BlockHistogram': $className .= '\\'.$name; diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php new file mode 100644 index 0000000000..a6ca136d32 --- /dev/null +++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php @@ -0,0 +1,883 @@ +width = $width; + + // Height. + $this->height = $height; + + // Grid Width. + $this->gridWidth = $gridWidth; + + // Cell Id. + $this->cellId = $cellId; + + // Options. + $this->values = $this->decoders($this->getOptionsWidget()); + + // Positions. + $this->position = $this->getPositionWidget(); + + // Page. + $this->page = basename(__FILE__); + + // ClassName. + $class = new \ReflectionClass($this); + $this->className = $class->getShortName(); + + // Title. + $this->title = __('Color tabs modules'); + + // Name. + if (empty($this->name) === true) { + $this->name = 'single_graph'; + } + + // This forces at least a first configuration. + $this->configurationRequired = false; + if (empty($this->values['moduleGroupedMeterGraphs']) === true) { + $this->configurationRequired = true; + } + + $this->overflow_scrollbars = false; + } + + + /** + * Decoders hack for retrocompability. + * + * @param array $decoder Values. + * + * @return array Returns the values ​​with the correct key. + */ + public function decoders(array $decoder): array + { + $values = []; + // Retrieve global - common inputs. + $values = parent::decoders($decoder); + + $values['agentsGroupedMeterGraphs'] = []; + if (isset($decoder['agentsGroupedMeterGraphs']) === true) { + if (isset($decoder['agentsGroupedMeterGraphs'][0]) === true + && empty($decoder['agentsGroupedMeterGraphs']) === false + ) { + $values['agentsGroupedMeterGraphs'] = explode( + ',', + $decoder['agentsGroupedMeterGraphs'][0] + ); + } + } + + if (isset($decoder['selectionGroupedMeterGraphs']) === true) { + $values['selectionGroupedMeterGraphs'] = $decoder['selectionGroupedMeterGraphs']; + } + + $values['moduleGroupedMeterGraphs'] = []; + if (isset($decoder['moduleGroupedMeterGraphs']) === true) { + if (empty($decoder['moduleGroupedMeterGraphs']) === false) { + $values['moduleGroupedMeterGraphs'] = $decoder['moduleGroupedMeterGraphs']; + } + } + + if (isset($decoder['formatData']) === true) { + $values['formatData'] = $decoder['formatData']; + } + + $values['label'] = 'module'; + if (isset($decoder['label']) === true) { + $values['label'] = $decoder['label']; + } + + $values['min_critical'] = null; + if (isset($decoder['min_critical']) === true) { + $values['min_critical'] = $decoder['min_critical']; + } + + $values['max_critical'] = null; + if (isset($decoder['max_critical']) === true) { + $values['max_critical'] = $decoder['max_critical']; + } + + $values['min_warning'] = null; + if (isset($decoder['min_warning']) === true) { + $values['min_warning'] = $decoder['min_warning']; + } + + $values['max_warning'] = null; + if (isset($decoder['max_warning']) === true) { + $values['max_warning'] = $decoder['max_warning']; + } + + if (isset($decoder['fontColor']) === true) { + $values['fontColor'] = $decoder['fontColor']; + } + + return $values; + } + + + /** + * Generates inputs for form (specific). + * + * @return array Of inputs. + * + * @throws Exception On error. + */ + public function getFormInputs(): array + { + $values = $this->values; + + // Retrieve global - common inputs. + $inputs = parent::getFormInputs(); + + $blocks = [ + 'row1', + 'row2', + ]; + + $inputs['blocks'] = $blocks; + + foreach ($inputs as $kInput => $vInput) { + $inputs['inputs']['row1'][] = $vInput; + } + + if (empty($values['fontColor']) === true) { + $values['fontColor'] = '#2c3e50'; + } + + $inputs['inputs']['row1'][] = [ + 'label' => __('Font color'), + 'arguments' => [ + 'wrapper' => 'div', + 'name' => 'fontColor', + 'type' => 'color', + 'value' => $values['fontColor'], + 'return' => true, + ], + ]; + + // Format Data. + $inputs['inputs']['row1'][] = [ + 'label' => __('Format Data'), + 'arguments' => [ + 'name' => 'formatData', + 'id' => 'formatData', + 'type' => 'switch', + 'value' => $values['formatData'], + ], + ]; + + $inputs['inputs']['row1'][] = [ + 'class' => 'dashboard-input-threshold', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Warning threshold'), + 'arguments' => [], + ], + [ + 'label' => __('Min'), + 'arguments' => [ + 'name' => 'min_warning', + 'id' => 'min_warning', + 'type' => 'number', + 'value' => $values['min_warning'], + ], + ], + [ + 'label' => __('Max'), + 'arguments' => [ + 'name' => 'max_warning', + 'id' => 'max_warning', + 'type' => 'number', + 'value' => $values['max_warning'], + ], + ], + ], + ]; + + $inputs['inputs']['row1'][] = [ + 'class' => 'dashboard-input-threshold', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Critical threshold'), + 'arguments' => [], + ], + [ + 'label' => __('Min'), + 'arguments' => [ + 'name' => 'min_critical', + 'id' => 'min_critical', + 'type' => 'number', + 'value' => $values['min_critical'], + ], + ], + [ + 'label' => __('Max'), + 'arguments' => [ + 'name' => 'max_critical', + 'id' => 'max_critical', + 'type' => 'number', + 'value' => $values['max_critical'], + ], + ], + ], + + ]; + + // Type Label. + $fields = [ + 'module' => __('Module'), + 'agent' => __('Agent'), + 'agent_module' => __('Agent / module'), + ]; + + $inputs['inputs']['row2'][] = [ + 'label' => __('Label'), + 'arguments' => [ + 'type' => 'select', + 'fields' => $fields, + 'name' => 'label', + 'selected' => $values['label'], + 'return' => true, + ], + ]; + + $inputs['inputs']['row2'][] = [ + 'arguments' => [ + 'type' => 'select_multiple_modules_filtered_select2', + 'agent_values' => agents_get_agents_selected(0), + 'agent_name' => 'agentsGroupedMeterGraphs[]', + 'agent_ids' => $values['agentsGroupedMeterGraphs'], + 'selectionModules' => $values['selectionGroupedMeterGraphs'], + 'selectionModulesNameId' => 'selectionGroupedMeterGraphs', + 'modules_ids' => $values['moduleGroupedMeterGraphs'], + 'modules_name' => 'moduleGroupedMeterGraphs[]', + ], + ]; + + return $inputs; + } + + + /** + * Get Post for widget. + * + * @return array + */ + public function getPost():array + { + // Retrieve global - common inputs. + $values = parent::getPost(); + + $values['agentsGroupedMeterGraphs'] = \get_parameter( + 'agentsGroupedMeterGraphs', + [] + ); + $values['selectionGroupedMeterGraphs'] = \get_parameter( + 'selectionGroupedMeterGraphs', + 0 + ); + + $values['moduleGroupedMeterGraphs'] = \get_parameter( + 'moduleGroupedMeterGraphs' + ); + + $agColor = []; + if (isset($values['agentsGroupedMeterGraphs'][0]) === true + && empty($values['agentsGroupedMeterGraphs'][0]) === false + ) { + $agColor = explode(',', $values['agentsGroupedMeterGraphs'][0]); + } + + $agModule = []; + if (isset($values['moduleGroupedMeterGraphs'][0]) === true + && empty($values['moduleGroupedMeterGraphs'][0]) === false + ) { + $agModule = explode(',', $values['moduleGroupedMeterGraphs'][0]); + } + + $values['moduleGroupedMeterGraphs'] = get_same_modules_all( + $agColor, + $agModule + ); + + $values['formatData'] = \get_parameter_switch('formatData', 0); + + $values['fontColor'] = \get_parameter('fontColor', '#2c3e50'); + + $values['label'] = \get_parameter('label', 'module'); + + $values['min_critical'] = \get_parameter('min_critical', null); + $values['max_critical'] = \get_parameter('max_critical', null); + $values['min_warning'] = \get_parameter('min_warning', null); + $values['max_warning'] = \get_parameter('max_warning', null); + + return $values; + } + + + /** + * Draw widget. + * + * @return string; + */ + public function load() + { + $this->size = parent::getSize(); + $this->boxNumber = ceil(($this->size['width'] * 0.65) / self::RATIO_WITH_BOX); + + $output = ''; + if (is_metaconsole() === true) { + $modules_nodes = array_reduce( + $this->values['moduleGroupedMeterGraphs'], + function ($carry, $item) { + $explode = explode('|', $item); + $carry[$explode[0]][] = $explode[1]; + return $carry; + }, + [] + ); + + $modules = []; + foreach ($modules_nodes as $n => $mod) { + try { + $node = new Node((int) $n); + $node->connect(); + $node_mods = $this->getInfoModules($mod); + if (empty($node_mods) === false) { + foreach ($node_mods as $value) { + $value['id_node'] = $n; + $value['server_name'] = $node->toArray()['server_name']; + $modules[] = $value; + } + } + + $node->disconnect(); + } catch (\Exception $e) { + // Unexistent agent. + $node->disconnect(); + } + } + } else { + $modules = $this->getInfoModules( + $this->values['moduleGroupedMeterGraphs'] + ); + } + + if ($modules !== false && empty($modules) === false) { + $moduleData = array_map( + function ($module) { + return ($module['data'] ?? 0); + }, + $modules + ); + + $tresholdData = [ + ($this->values['min_critical'] ?? 0), + ($this->values['max_critical'] ?? 0), + ($this->values['min_warning'] ?? 0), + ($this->values['max_warning'] ?? 0), + ]; + + $max = max( + array_merge( + $moduleData, + $tresholdData + ) + ); + + $min = min( + array_merge( + $moduleData, + $tresholdData + ) + ); + + $this->thresholds = $this->calculateThreshold($max, $min); + + $output .= '
'; + foreach ($modules as $module) { + $output .= $this->drawRowModule( + $module, + $max + ); + } + + $output .= '
'; + } else { + $output .= '
'; + $output .= \ui_print_info_message( + __('Not found modules'), + '', + true + ); + $output .= '
'; + } + + return $output; + } + + + /** + * Get info modules. + * + * @param array $modules Modules. + * + * @return array Data. + */ + private function getInfoModules(array $modules): array + { + $where = sprintf( + 'tagente_modulo.id_agente_modulo IN (%s) + AND tagente_modulo.delete_pending = 0', + implode(',', $modules) + ); + + $sql = sprintf( + 'SELECT tagente_modulo.id_agente_modulo AS `id`, + tagente_modulo.nombre AS `name`, + tagente_modulo.unit AS `unit`, + tagente_modulo.min_warning AS w_min, + tagente_modulo.max_warning AS w_max, + tagente_modulo.str_warning AS w_str, + tagente_modulo.min_critical AS c_min, + tagente_modulo.max_critical AS c_max, + tagente_modulo.str_critical AS c_str, + tagente_modulo.id_tipo_modulo AS type_module, + tagente_estado.datos AS `data`, + tagente_estado.timestamp AS `timestamp`, + tagente_estado.estado AS `status`, + tagente.alias + FROM tagente_modulo + LEFT JOIN tagente_estado + ON tagente_modulo.id_agente_modulo = tagente_estado.id_agente_modulo + LEFT JOIN tagente + ON tagente_modulo.id_agente = tagente.id_agente + WHERE %s', + $where + ); + + $modules = db_get_all_rows_sql($sql); + + if ($modules === false) { + $modules = []; + } + + return $modules; + } + + + /** + * Draw info module. + * + * @param array $data Data module. + * @param float $max Value max. + * + * @return string + */ + private function drawRowModule( + array $data, + float $max + ):string { + global $config; + + $module_data = $this->getBoxPercentageMaths($max, $data['data']); + + $output = ''; + $output .= '
'; + + // Module name. + $output .= '
'; + $name = ''; + switch ($this->values['label']) { + case 'agent': + $name = $data['alias']; + break; + + case 'agent_module': + $name = $data['alias'].' / '.$data['name']; + break; + + default: + case 'module': + $name = $data['name']; + break; + } + + $output .= $name; + $output .= '
'; + + // Graphs. + $output .= '
'; + for ($i = 0; $i < $this->boxNumber; $i++) { + $class = 'meter-graph-'; + $class .= $this->getThresholdStatus($i); + + if ($module_data > $i) { + $class .= ' meter-graph-opacity'; + } + + $output .= '
'; + $output .= '
'; + } + + $output .= '
'; + + // Data. + $class = 'container-info-module-meter-data'; + $class .= ' meter-data-'; + $class .= $this->getThresholdStatus($module_data); + + $output .= '
'; + if ($data['data'] !== null && $data['data'] !== '') { + if (isset($this->values['formatData']) === true + && (bool) $this->values['formatData'] === true + ) { + $output .= format_for_graph( + $data['data'], + $config['graph_precision'] + ); + } else { + $output .= sla_truncate( + $data['data'], + $config['graph_precision'] + ); + } + + $output .= ' '.$data['unit']; + } else { + $output .= '--'; + } + + $output .= '
'; + + $output .= '
'; + + return $output; + } + + + /** + * Get status. + * + * @return array + */ + private static function getStatuses() + { + return [ + self::STATUS_CRITICAL, + self::STATUS_WARNING, + self::STATUS_NORMAL, + ]; + } + + + /** + * Get tresholds. + * + * @param float $max Value max. + * @param float $min Value min. + * + * @return array Array threshold. + */ + private function calculateThreshold(float $max, float $min) + { + $nMax = null; + if ($this->values['min_warning'] !== null) { + $nMax = $this->getBoxPercentageMaths($max, $this->values['min_warning']); + } + + $wMin = null; + if ($this->values['min_warning'] !== null) { + $wMin = $this->getBoxPercentageMaths($max, $this->values['min_warning']); + } + + $wMax = null; + if ($this->values['max_warning'] !== null) { + $wMax = $this->getBoxPercentageMaths($max, $this->values['max_warning']); + } + + $cMin = null; + if ($this->values['min_critical'] !== null) { + $cMin = $this->getBoxPercentageMaths($max, $this->values['min_critical']); + } + + $cMax = null; + if ($this->values['max_critical'] !== null) { + $cMax = $this->getBoxPercentageMaths($max, $this->values['max_critical']); + } + + $thresholds = [ + 'normal' => [ + 'min' => $min, + 'max' => $nMax, + ], + 'warning' => [ + 'min' => $wMin, + 'max' => $wMax, + ], + 'critical' => [ + 'min' => $cMin, + 'max' => $cMax, + ], + ]; + + return $thresholds; + } + + + /** + * Get porcentage. + * + * @param float $max Maximum. + * @param float $value Value. + * + * @return float + */ + private function getBoxPercentageMaths(float $max, float $value):float + { + return (($value / $max) * $this->boxNumber); + } + + + /** + * Get status compare tresholds. + * + * @param float $value Value to compare. + * + * @return string + */ + private function getThresholdStatus( + float $value + ) { + foreach (self::getStatuses() as $status) { + if ($this->thresholds[$status]['min'] === null + && $this->thresholds[$status]['max'] === null + ) { + continue; + } + + if (($this->thresholds[$status]['min'] === null + && $this->thresholds[$status]['max'] >= $value) + || ($this->thresholds[$status]['max'] === null + && $this->thresholds[$status]['min'] <= $value) + || ($this->thresholds[$status]['min'] <= $value + && $this->thresholds[$status]['max'] >= $value) + ) { + return $status; + } + } + + return self::STATUS_NORMAL; + } + + + /** + * Get description. + * + * @return string. + */ + public static function getDescription() + { + return __('Grouped meter graphs'); + } + + + /** + * Get Name. + * + * @return string. + */ + public static function getName() + { + return 'GroupedMeterGraphs'; + } + + + /** + * Get size Modal Configuration. + * + * @return array + */ + public function getSizeModalConfiguration(): array + { + $size = [ + 'width' => (is_metaconsole() === true) ? 1000 : 900, + 'height' => 480, + ]; + + return $size; + } + + +} diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index e8ab6204d9..973881ffc8 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -677,6 +677,128 @@ form.modal-dashboard text-align: initial; } +.container-grouped-meter { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + width: 98%; + padding: 5px; +} +.container-grouped-meter .container-info-module-meter { + display: flex; + flex-direction: row; + justify-content: center; + align-items: center; + width: 100%; + height: 30px; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-title { + flex: 1 1 20%; + font-size: 100%; + font-weight: bolder; + text-align: right; + padding-right: 10px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-graphs { + flex: 1 1 65%; + display: flex; + flex-direction: row; + justify-content: space-around; + align-items: center; + height: 100%; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-graphs + div { + border-radius: 2px; + width: 17px; + height: 90%; + opacity: 0.4; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-graphs + div.meter-graph-critical { + background-color: #e63c52; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-graphs + div.meter-graph-warning { + background-color: #f3b200; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-graphs + div.meter-graph-normal { + background-color: #82b92e; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-graphs + div.meter-graph-opacity { + opacity: 1; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-data { + flex: 1 1 15%; + font-size: 150%; + font-weight: bolder; + text-align: right; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-data.meter-data-critical { + color: #e63c52; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-data.meter-data-warning { + color: #f3b200; +} + +.container-grouped-meter + .container-info-module-meter + .container-info-module-meter-data.meter-data-normal { + color: #82b92e; +} + +.dashboard-input-threshold { + align-items: center; + justify-content: space-between; +} + +.dashboard-input-threshold input { + max-width: 20% !important; +} + +.dashboard-input-threshold label:not(:first-child) { + flex: 0 !important; +} + .content-widget .dataTables_wrapper { width: 98%; margin-top: 5px; From 54b44cc7fc6f4d04cb26bdb83d42960da8a99106 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Thu, 6 Oct 2022 09:41:31 +0200 Subject: [PATCH 2/6] new widget grouped meter graphs pandora_enterprise#8620 --- .../Dashboard/Widgets/GroupedMeterGraphs.php | 38 ++++++++++++++----- pandora_console/include/styles/dashboards.css | 1 - 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php index a6ca136d32..9ba51eeefb 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php +++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php @@ -41,6 +41,7 @@ class GroupedMeterGraphs extends Widget private const STATUS_CRITICAL = 'critical'; private const STATUS_WARNING = 'warning'; private const RATIO_WITH_BOX = 20.1518; + private const MAX_MODULES = 20; /** * Name widget. @@ -66,14 +67,14 @@ class GroupedMeterGraphs extends Widget /** * Class name widget. * - * @var [type] + * @var string */ protected $className; /** * Values options for each widget. * - * @var [type] + * @var array */ protected $values; @@ -534,7 +535,24 @@ class GroupedMeterGraphs extends Widget ); } - if ($modules !== false && empty($modules) === false) { + if ($modules !== false + && empty($modules) === false + && is_array($modules) === true + ) { + if (count($modules) > self::MAX_MODULES) { + $output .= '
'; + $output .= \ui_print_info_message( + __( + 'The maximum number of modules to display is %d, please reconfigure the widget.', + self::MAX_MODULES + ), + '', + true + ); + $output .= '
'; + return $output; + } + $moduleData = array_map( function ($module) { return ($module['data'] ?? 0); @@ -657,7 +675,6 @@ class GroupedMeterGraphs extends Widget $output .= '
'; // Module name. - $output .= '
'; $name = ''; switch ($this->values['label']) { case 'agent': @@ -674,6 +691,7 @@ class GroupedMeterGraphs extends Widget break; } + $output .= '
'; $output .= $name; $output .= '
'; @@ -698,27 +716,29 @@ class GroupedMeterGraphs extends Widget $class .= ' meter-data-'; $class .= $this->getThresholdStatus($module_data); - $output .= '
'; + $result_data = ''; if ($data['data'] !== null && $data['data'] !== '') { if (isset($this->values['formatData']) === true && (bool) $this->values['formatData'] === true ) { - $output .= format_for_graph( + $result_data .= format_for_graph( $data['data'], $config['graph_precision'] ); } else { - $output .= sla_truncate( + $result_data .= sla_truncate( $data['data'], $config['graph_precision'] ); } - $output .= ' '.$data['unit']; + $result_data .= ' '.$data['unit']; } else { - $output .= '--'; + $result_data .= '--'; } + $output .= '
'; + $output .= $result_data; $output .= '
'; $output .= '
'; diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 973881ffc8..1f01152379 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -683,7 +683,6 @@ form.modal-dashboard justify-content: center; align-items: center; width: 98%; - padding: 5px; } .container-grouped-meter .container-info-module-meter { display: flex; From 014441a2daa8a7f39deedfbaac9cc3a0723c07ec Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Thu, 6 Oct 2022 17:13:45 +0200 Subject: [PATCH 3/6] new widget grouped meter graphs pandora_enterprise#8620 --- .../Dashboard/Widgets/GroupedMeterGraphs.php | 224 ++++++++++++++---- 1 file changed, 176 insertions(+), 48 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php index 9ba51eeefb..b88414d623 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php +++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php @@ -42,6 +42,7 @@ class GroupedMeterGraphs extends Widget private const STATUS_WARNING = 'warning'; private const RATIO_WITH_BOX = 20.1518; private const MAX_MODULES = 20; + private const MAX_INCREASE = 0.10; /** * Name widget. @@ -257,6 +258,16 @@ class GroupedMeterGraphs extends Widget $values['label'] = $decoder['label']; } + $values['min_value'] = null; + if (isset($decoder['min_value']) === true) { + $values['min_value'] = $decoder['min_value']; + } + + $values['max_value'] = null; + if (isset($decoder['max_value']) === true) { + $values['max_value'] = $decoder['max_value']; + } + $values['min_critical'] = null; if (isset($decoder['min_critical']) === true) { $values['min_critical'] = $decoder['min_critical']; @@ -336,6 +347,36 @@ class GroupedMeterGraphs extends Widget ], ]; + $inputs['inputs']['row1'][] = [ + 'class' => 'dashboard-input-threshold', + 'direct' => 1, + 'block_content' => [ + [ + 'label' => __('Values'), + 'arguments' => [], + ], + [ + 'label' => __('Min'), + 'arguments' => [ + 'name' => 'min_value', + 'id' => 'min_value', + 'type' => 'number', + 'value' => $values['min_value'], + ], + ], + [ + 'label' => __('Max'), + 'arguments' => [ + 'name' => 'max_value', + 'id' => 'max_value', + 'type' => 'number', + 'value' => $values['max_value'], + ], + ], + ], + + ]; + $inputs['inputs']['row1'][] = [ 'class' => 'dashboard-input-threshold', 'direct' => 1, @@ -478,6 +519,9 @@ class GroupedMeterGraphs extends Widget $values['label'] = \get_parameter('label', 'module'); + $values['min_value'] = \get_parameter('min_value', null); + $values['max_value'] = \get_parameter('max_value', null); + $values['min_critical'] = \get_parameter('min_critical', null); $values['max_critical'] = \get_parameter('max_critical', null); $values['min_warning'] = \get_parameter('min_warning', null); @@ -553,41 +597,75 @@ class GroupedMeterGraphs extends Widget return $output; } - $moduleData = array_map( - function ($module) { - return ($module['data'] ?? 0); - }, - $modules - ); + $max = null; + $min = null; + // Dinamic treshold. + if ($this->values['min_critical'] !== null + || $this->values['max_critical'] !== null + || $this->values['min_warning'] !== null + || $this->values['max_warning'] !== null + ) { + if ($this->values['max_value'] === null || $this->values['min_value'] === null) { + $tresholdData = [ + ($this->values['min_critical'] ?? 0), + ($this->values['max_critical'] ?? 0), + ($this->values['min_warning'] ?? 0), + ($this->values['max_warning'] ?? 0), + ]; - $tresholdData = [ - ($this->values['min_critical'] ?? 0), - ($this->values['max_critical'] ?? 0), - ($this->values['min_warning'] ?? 0), - ($this->values['max_warning'] ?? 0), - ]; + $moduleData = array_map( + function ($module) { + return ($module['data'] ?? 0); + }, + $modules + ); + } - $max = max( - array_merge( - $moduleData, - $tresholdData - ) - ); + if ($this->values['max_value'] === null) { + $max = max( + array_merge( + $moduleData, + $tresholdData + ) + ); + } else { + $max = $this->values['max_value']; + } - $min = min( - array_merge( - $moduleData, - $tresholdData - ) - ); + // Increases max. + if ($this->values['max_critical'] === null && $this->values['max_value'] === null) { + $max_increase = ($max * self::MAX_INCREASE); + $max = ($max + $max_increase); + } - $this->thresholds = $this->calculateThreshold($max, $min); + if ($this->values['min_value'] === null) { + $min = min( + array_merge( + $moduleData, + $tresholdData + ) + ); + } else { + $min = $this->values['min_value']; + } - $output .= '
'; + $tresholds_array = [ + 'min_critical' => $this->values['min_critical'], + 'max_critical' => $this->values['max_critical'], + 'min_warning' => $this->values['min_warning'], + 'max_warning' => $this->values['max_warning'], + ]; + + $this->thresholds = $this->calculateThreshold($max, $min, $tresholds_array); + } + + $style = 'color:'.$this->values['fontColor'].';'; + $output .= '
'; foreach ($modules as $module) { $output .= $this->drawRowModule( $module, - $max + $max, + $min ); } @@ -658,18 +736,63 @@ class GroupedMeterGraphs extends Widget /** * Draw info module. * - * @param array $data Data module. - * @param float $max Value max. + * @param array $data Data module. + * @param null|float $max Value max. + * @param null|float $min Value min. * * @return string */ private function drawRowModule( array $data, - float $max + ?float $max, + ?float $min ):string { global $config; - $module_data = $this->getBoxPercentageMaths($max, $data['data']); + // Dinamic. + if ($max === null && $min === null) { + $all_values_module = [ + ($data['w_min'] ?? 0), + ($data['w_max'] ?? 0), + ($data['c_min'] ?? 0), + ($data['c_max'] ?? 0), + ($data['data'] ?? 0), + ]; + + if ($this->values['max_value'] === null) { + $max = max($all_values_module); + } else { + $max = $this->values['max_value']; + } + + // Increases max. + if (empty($data['c_max']) === true + && $this->values['max_value'] === null + ) { + $max_increase = ($max * self::MAX_INCREASE); + $max = ($max + $max_increase); + } + + $min = 0; + if ($this->values['min_value'] !== null) { + $min = $this->values['min_value']; + } + + $thresholds_array = [ + 'min_critical' => (empty($data['c_min']) === true) ? null : $data['c_min'], + 'max_critical' => (empty($data['c_max']) === true) ? null : $data['c_max'], + 'min_warning' => (empty($data['w_min']) === true) ? null : $data['w_min'], + 'max_warning' => (empty($data['w_max']) === true) ? null : $data['w_max'], + ]; + + $this->thresholds = $this->calculateThreshold( + $max, + $min, + $thresholds_array + ); + } + + $module_data = $this->getBoxPercentageMaths($max, $min, $data['data']); $output = ''; $output .= '
'; @@ -765,41 +888,42 @@ class GroupedMeterGraphs extends Widget /** * Get tresholds. * - * @param float $max Value max. - * @param float $min Value min. + * @param float $max Value max. + * @param float $min Value min. + * @param array $thresholds_array Array thresholds. * * @return array Array threshold. */ - private function calculateThreshold(float $max, float $min) + private function calculateThreshold(float $max, float $min, array $thresholds_array) { $nMax = null; - if ($this->values['min_warning'] !== null) { - $nMax = $this->getBoxPercentageMaths($max, $this->values['min_warning']); + if ($thresholds_array['min_warning'] !== null) { + $nMax = $this->getBoxPercentageMaths($max, $min, $thresholds_array['min_warning']); } $wMin = null; - if ($this->values['min_warning'] !== null) { - $wMin = $this->getBoxPercentageMaths($max, $this->values['min_warning']); + if ($thresholds_array['min_warning'] !== null) { + $wMin = $this->getBoxPercentageMaths($max, $min, $thresholds_array['min_warning']); } $wMax = null; - if ($this->values['max_warning'] !== null) { - $wMax = $this->getBoxPercentageMaths($max, $this->values['max_warning']); + if ($thresholds_array['max_warning'] !== null) { + $wMax = $this->getBoxPercentageMaths($max, $min, $thresholds_array['max_warning']); } $cMin = null; - if ($this->values['min_critical'] !== null) { - $cMin = $this->getBoxPercentageMaths($max, $this->values['min_critical']); + if ($thresholds_array['min_critical'] !== null) { + $cMin = $this->getBoxPercentageMaths($max, $min, $thresholds_array['min_critical']); } $cMax = null; - if ($this->values['max_critical'] !== null) { - $cMax = $this->getBoxPercentageMaths($max, $this->values['max_critical']); + if ($thresholds_array['max_critical'] !== null) { + $cMax = $this->getBoxPercentageMaths($max, $min, $thresholds_array['max_critical']); } $thresholds = [ 'normal' => [ - 'min' => $min, + 'min' => $this->getBoxPercentageMaths($max, $min, $min), 'max' => $nMax, ], 'warning' => [ @@ -820,13 +944,17 @@ class GroupedMeterGraphs extends Widget * Get porcentage. * * @param float $max Maximum. + * @param float $min Minimum. * @param float $value Value. * * @return float */ - private function getBoxPercentageMaths(float $max, float $value):float - { - return (($value / $max) * $this->boxNumber); + private function getBoxPercentageMaths( + float $max, + float $min, + float $value + ):float { + return (((($value - $min) / ($max - $min))) * $this->boxNumber); } From ce823dca38eb265c87ed05105ad7f3f220595427 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Mon, 10 Oct 2022 11:20:03 +0200 Subject: [PATCH 4/6] new widget grouped meter graphs pandora_enterprise#8620 --- pandora_console/include/functions_agents.php | 35 +++++++++++++++---- pandora_console/include/functions_html.php | 4 ++- pandora_console/include/functions_modules.php | 30 +++++++++++++--- .../include/javascript/pandora_dashboards.js | 15 ++++++++ .../Dashboard/Widgets/GroupedMeterGraphs.php | 35 ++++++++++++++++--- pandora_console/include/styles/dashboards.css | 1 + 6 files changed, 104 insertions(+), 16 deletions(-) diff --git a/pandora_console/include/functions_agents.php b/pandora_console/include/functions_agents.php index 178088195c..c0d91e35f1 100644 --- a/pandora_console/include/functions_agents.php +++ b/pandora_console/include/functions_agents.php @@ -3487,12 +3487,13 @@ function agents_get_agent_custom_field($agent_id, $custom_field_name) /** * Unverified documentation. * - * @param integer $id_group Module group. - * @param array $id_agents Array of agent ids. - * @param boolean $selection Show common (false) or all modules (true). - * @param boolean $return Return (false) or dump to output (true). - * @param boolean $index_by_name Use module name as key. - * @param boolean $pure_return Return as retrieved from DB. + * @param integer $id_group Module group. + * @param array $id_agents Array of agent ids. + * @param boolean $selection Show common (false) or all modules (true). + * @param boolean $return Return (false) or dump to output (true). + * @param boolean $index_by_name Use module name as key. + * @param boolean $pure_return Return as retrieved from DB. + * @param boolean $notStringModules Not string modules. * * @return array With modules or null if error. */ @@ -3502,7 +3503,8 @@ function select_modules_for_agent_group( $selection, $return=true, $index_by_name=false, - $pure_return=false + $pure_return=false, + $notStringModules=false ) { global $config; $agents = (empty($id_agents)) ? [] : implode(',', $id_agents); @@ -3510,6 +3512,7 @@ function select_modules_for_agent_group( $filter_agent_group = ''; $filter_group = ''; $filter_agent = ''; + $filter_not_string_modules = ''; $selection_filter = ''; $sql_conditions_tags = ''; $sql_tags_inner = ''; @@ -3524,6 +3527,23 @@ function select_modules_for_agent_group( $filter_agent = ' AND tagente.id_agente IN ('.$agents.')'; } + if ($notStringModules === true) { + $filter_not_string_modules = sprintf( + ' AND (tagente_modulo.id_tipo_modulo <> %d AND + tagente_modulo.id_tipo_modulo <> %d AND + tagente_modulo.id_tipo_modulo <> %d AND + tagente_modulo.id_tipo_modulo <> %d AND + tagente_modulo.id_tipo_modulo <> %d AND + tagente_modulo.id_tipo_modulo <> %d)', + MODULE_TYPE_GENERIC_DATA_STRING, + MODULE_TYPE_REMOTE_TCP_STRING, + MODULE_TYPE_REMOTE_SNMP_STRING, + MODULE_TYPE_ASYNC_STRING, + MODULE_TYPE_WEB_CONTENT_STRING, + MODULE_TYPE_REMOTE_CMD_STRING + ); + } + if (!users_can_manage_group_all('AR')) { $group_string = implode(',', $groups); $filter_agent_group = " AND ( @@ -3567,6 +3587,7 @@ function select_modules_for_agent_group( $filter_agent_group $filter_group $filter_agent + $filter_not_string_modules $sql_conditions_tags ) x GROUP BY nombre diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index c519645560..e0b35678c0 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -5608,7 +5608,9 @@ function html_print_input($data, $wrapper='div', $input_only=false) 0, $data['agent_ids'], $data['selectionModules'], - true + true, + false, + (isset($data['notStringModules']) === true && $data['notStringModules'] === true) ? true : false ); } diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 6c265e8e0f..49521d8b1d 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -3607,8 +3607,26 @@ function modules_get_agentmodule_mininterval_no_async($id_agent) } -function get_modules_agents($id_module_group, $id_agents, $selection, $select_mode=true, $useName=false) -{ +/** + * Get modules agents. + * + * @param integer $id_module_group ID module group. + * @param array $id_agents Array agents. + * @param boolean $selection Selection. + * @param boolean $select_mode Mode. + * @param boolean $useName Use name. + * @param boolean $notStringModules Not string modules. + * + * @return array Modules for this agents. + */ +function get_modules_agents( + $id_module_group, + $id_agents, + $selection, + $select_mode=true, + $useName=false, + $notStringModules=false +) { if ((bool) is_metaconsole() === true) { if ($select_mode === true) { $agents = array_reduce( @@ -3657,7 +3675,8 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo $selection, false, false, - true + true, + $notStringModules ); metaconsole_restore_db(); @@ -3744,7 +3763,10 @@ function get_modules_agents($id_module_group, $id_agents, $selection, $select_mo $id_module_group, $id_agents, $selection, - false + false, + false, + false, + $notStringModules ); } diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index f6e4445744..c08e6bdbf7 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -1536,3 +1536,18 @@ function loadSliceWidget(settings) { } }); } + +// eslint-disable-next-line no-unused-vars +function showManualThresholds(element) { + $("#min_warning").val(null); + $("#max_warning").val(null); + $("#min_critical").val(null); + $("#max_critical").val(null); + if ($(element).is(":checked") === true) { + $(".dashboard-input-threshold-warning").removeClass("invisible_important"); + $(".dashboard-input-threshold-critical").removeClass("invisible_important"); + } else { + $(".dashboard-input-threshold-warning").addClass("invisible_important"); + $(".dashboard-input-threshold-critical").addClass("invisible_important"); + } +} diff --git a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php index b88414d623..fcca4b5968 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php +++ b/pandora_console/include/lib/Dashboard/Widgets/GroupedMeterGraphs.php @@ -253,6 +253,10 @@ class GroupedMeterGraphs extends Widget $values['formatData'] = $decoder['formatData']; } + if (isset($decoder['manualThresholds']) === true) { + $values['manualThresholds'] = $decoder['manualThresholds']; + } + $values['label'] = 'module'; if (isset($decoder['label']) === true) { $values['label'] = $decoder['label']; @@ -377,8 +381,25 @@ class GroupedMeterGraphs extends Widget ]; + // Format Data. $inputs['inputs']['row1'][] = [ - 'class' => 'dashboard-input-threshold', + 'label' => __('Manual thresholds'), + 'arguments' => [ + 'name' => 'manualThresholds', + 'id' => 'manualThresholds', + 'type' => 'switch', + 'value' => $values['manualThresholds'], + 'onchange' => 'showManualThresholds(this)', + ], + ]; + + $class_invisible = ''; + if ((bool) $values['manualThresholds'] !== true) { + $class_invisible = 'invisible_important'; + } + + $inputs['inputs']['row1'][] = [ + 'class' => 'dashboard-input-threshold dashboard-input-threshold-warning '.$class_invisible, 'direct' => 1, 'block_content' => [ [ @@ -407,7 +428,7 @@ class GroupedMeterGraphs extends Widget ]; $inputs['inputs']['row1'][] = [ - 'class' => 'dashboard-input-threshold', + 'class' => 'dashboard-input-threshold dashboard-input-threshold-critical '.$class_invisible, 'direct' => 1, 'block_content' => [ [ @@ -464,6 +485,7 @@ class GroupedMeterGraphs extends Widget 'selectionModulesNameId' => 'selectionGroupedMeterGraphs', 'modules_ids' => $values['moduleGroupedMeterGraphs'], 'modules_name' => 'moduleGroupedMeterGraphs[]', + 'notStringModules' => true, ], ]; @@ -522,6 +544,7 @@ class GroupedMeterGraphs extends Widget $values['min_value'] = \get_parameter('min_value', null); $values['max_value'] = \get_parameter('max_value', null); + $values['manualThresholds'] = \get_parameter_switch('manualThresholds', 0); $values['min_critical'] = \get_parameter('min_critical', null); $values['max_critical'] = \get_parameter('max_critical', null); $values['min_warning'] = \get_parameter('min_warning', null); @@ -792,7 +815,7 @@ class GroupedMeterGraphs extends Widget ); } - $module_data = $this->getBoxPercentageMaths($max, $min, $data['data']); + $module_data = $this->getBoxPercentageMaths($max, $min, (float) $data['data']); $output = ''; $output .= '
'; @@ -954,6 +977,10 @@ class GroupedMeterGraphs extends Widget float $min, float $value ):float { + if ($min === 0.00 && $max === 0.00) { + return 0; + } + return (((($value - $min) / ($max - $min))) * $this->boxNumber); } @@ -1021,7 +1048,7 @@ class GroupedMeterGraphs extends Widget { $size = [ 'width' => (is_metaconsole() === true) ? 1000 : 900, - 'height' => 480, + 'height' => 550, ]; return $size; diff --git a/pandora_console/include/styles/dashboards.css b/pandora_console/include/styles/dashboards.css index 1f01152379..64c6fbe4b4 100644 --- a/pandora_console/include/styles/dashboards.css +++ b/pandora_console/include/styles/dashboards.css @@ -683,6 +683,7 @@ form.modal-dashboard justify-content: center; align-items: center; width: 98%; + margin-top: 10px; } .container-grouped-meter .container-info-module-meter { display: flex; From ab59537d42a2f2e1479fe996cd2c5be38598a157 Mon Sep 17 00:00:00 2001 From: Daniel Barbero Date: Mon, 10 Oct 2022 13:29:40 +0200 Subject: [PATCH 5/6] new widget grouped meter graphs pandora_enterprise#8620 --- .../images/widgets/GroupedMeterGraphs.png | Bin 0 -> 5458 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 pandora_console/images/widgets/GroupedMeterGraphs.png diff --git a/pandora_console/images/widgets/GroupedMeterGraphs.png b/pandora_console/images/widgets/GroupedMeterGraphs.png new file mode 100644 index 0000000000000000000000000000000000000000..b9e7ece040f6b9ffef97a0169a180490997abf0a GIT binary patch literal 5458 zcmV-Y6|L%tP)%tDsEg!U_>$IXELiOySl6;R%O*>%OtL~?kb`~%vuoeGbY(xlO-lbK!K2w zF^p9Pl|c$*`OU~M-}mOd`|iEl=e{|YzWw_C-g|du!0D=)?(^wBef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+s^~6^fotnIP+vGwIvnLXX*6yw(Y(3ih(0-#epu;d2Mqqd*jGaWT`t?yyy;@Ft zf9z3@#{ANU%u{`IC>u{jT!@NcnqU|CVM#K&%~;17($8pc=PIlw?Govx~}HYl4yvJ3VAyOiu^+e<%t>~D@8IrxCA$m)nhLWSD| zcoP6K2w%$iIJ1Y!)&G~Je)fWCwLf0*o%?@-dWZ4zZnk0MQr!t{|KwES(1CX+_I7p* z`CrmP-HY+dM~zO_%((p2*zps++glGIo_9joc*D1;+0uwM9QZahpN-*n2>22y9bE7` z1bh}~J39P=2VW=!!X Date: Tue, 18 Oct 2022 13:40:09 +0200 Subject: [PATCH 6/6] fixed multi selector pandora_enterprise#8620 --- .../include/lib/Dashboard/Widgets/agent_module.php | 10 +++++++--- pandora_console/operation/agentes/ver_agente.php | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php index d4eb582cfc..fbc4165b4d 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/agent_module.php +++ b/pandora_console/include/lib/Dashboard/Widgets/agent_module.php @@ -710,9 +710,13 @@ class AgentModuleWidget extends Widget if (empty($allModules) === false) { if (is_metaconsole() === true && $this->values['mShowCommonModules'] !== 'on') { - $modules = $agent->searchModules( - ['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])] - ); + if (isset($reduceAllModules['modules_selected'][$tserver]) === true) { + $modules = $agent->searchModules( + ['nombre' => array_keys($reduceAllModules['modules_selected'][$tserver])] + ); + } else { + $modules = null; + } } else { $modules = $agent->searchModules( ['nombre' => array_keys($allModules)] diff --git a/pandora_console/operation/agentes/ver_agente.php b/pandora_console/operation/agentes/ver_agente.php index d3797d127b..3e296bdeb2 100644 --- a/pandora_console/operation/agentes/ver_agente.php +++ b/pandora_console/operation/agentes/ver_agente.php @@ -223,7 +223,7 @@ if (is_ajax()) { $id_agents, $selection, $select_mode, - true + (bool) !$select_mode ); // Clean double safe input.