From 72614130a8c90240f267bb26ae0d8f2f12fafb3b Mon Sep 17 00:00:00 2001 From: Daniel Barbero Martin Date: Thu, 28 Jul 2022 14:25:31 +0200 Subject: [PATCH 1/4] fixed widget dashboards no exist item pandora_enterprise#9229 --- .../include/functions_reporting.php | 2 +- .../include/functions_visual_map.php | 125 +++++++++--------- .../include/graphs/functions_d3.php | 3 +- .../lib/Dashboard/Widgets/BlockHistogram.php | 23 ++-- .../lib/Dashboard/Widgets/ColorModuleTabs.php | 3 +- .../lib/Dashboard/Widgets/alerts_fired.php | 11 ++ .../lib/Dashboard/Widgets/custom_graph.php | 37 ++++++ .../Widgets/graph_module_histogram.php | 45 ++++++- .../lib/Dashboard/Widgets/groups_status.php | 13 +- .../Dashboard/Widgets/maps_made_by_user.php | 51 +++++-- .../lib/Dashboard/Widgets/maps_status.php | 33 ++++- .../lib/Dashboard/Widgets/module_icon.php | 42 +++++- .../lib/Dashboard/Widgets/module_status.php | 54 ++++++-- .../Dashboard/Widgets/module_table_value.php | 42 ++++++ .../lib/Dashboard/Widgets/module_value.php | 48 ++++++- .../lib/Dashboard/Widgets/monitor_health.php | 2 +- .../include/lib/Dashboard/Widgets/reports.php | 83 +++++++++--- .../lib/Dashboard/Widgets/service_map.php | 11 ++ .../lib/Dashboard/Widgets/service_view.php | 8 +- .../lib/Dashboard/Widgets/single_graph.php | 42 ++++++ .../lib/Dashboard/Widgets/sla_percent.php | 43 +++++- .../Dashboard/Widgets/system_group_status.php | 26 +++- .../lib/Dashboard/Widgets/tree_view.php | 7 +- .../rest-api/models/VisualConsole/Item.php | 6 +- pandora_console/include/styles/dashboards.css | 1 + 25 files changed, 613 insertions(+), 148 deletions(-) diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index c52b2bf5eb..855bf03c73 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -11387,7 +11387,7 @@ function reporting_get_group_stats_resume($id_group=0, $access='AR', $ignore_per $data['status'] = 'critical'; } else if ($data['monitor_warning'] > 0) { $data['status'] = 'warning'; - } else if (($data['monitor_unknown'] > 0) || ($data['agents_unknown'] > 0)) { + } else if (($data['monitor_unknown'] > 0) || ($data['agent_unknown'] > 0)) { $data['status'] = 'unknown'; } else if ($data['monitor_ok'] > 0) { $data['status'] = 'ok'; diff --git a/pandora_console/include/functions_visual_map.php b/pandora_console/include/functions_visual_map.php index 0ff126ed8a..fbe1289537 100755 --- a/pandora_console/include/functions_visual_map.php +++ b/pandora_console/include/functions_visual_map.php @@ -3788,6 +3788,7 @@ function visual_map_get_user_layouts( unset($filter['can_manage_group_all']); } + $where = ''; if ($check_user_groups === true && !empty($groups)) { if (empty($where)) { $where = ''; @@ -4080,7 +4081,7 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0) // When the status calculation type is 'default', only one critical // element is required to set the layout status as critical, so we can // return the critical status right now. - if ($status_data['linked_layout_status_type'] === 'default' + if ((isset($status_data['linked_layout_status_type']) === true && $status_data['linked_layout_status_type'] === 'default') && ($status == VISUAL_MAP_STATUS_CRITICAL_BAD || $status == VISUAL_MAP_STATUS_CRITICAL_ALERT) ) { @@ -4104,71 +4105,73 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0) metaconsole_restore_db(); } - // Status calculation. - switch ($status_data['linked_layout_status_type']) { - default: - case 'default': - $num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]; - $num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD]; - $num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]; - $num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING]; - $num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN]; + if (isset($status_data['linked_layout_status_type']) === true) { + // Status calculation. + switch ($status_data['linked_layout_status_type']) { + default: + case 'default': + $num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]; + $num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD]; + $num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]; + $num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING]; + $num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN]; - if ($num_items_critical_alert > 0) { - return VISUAL_MAP_STATUS_CRITICAL_ALERT; - } else if ($num_items_critical > 0) { - return VISUAL_MAP_STATUS_CRITICAL_BAD; - } else if ($num_items_warning_alert > 0) { - return VISUAL_MAP_STATUS_WARNING_ALERT; - } else if ($num_items_warning > 0) { - return VISUAL_MAP_STATUS_WARNING; - } else if ($num_items_unknown > 0) { - return VISUAL_MAP_STATUS_UNKNOWN; - } else { - return VISUAL_MAP_STATUS_NORMAL; - } - break; - case 'weight': - $weight = $status_data['id_layout_linked_weight']; - $num_items = count($valid_layout_items); - $num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]; - $num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD]; - $num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]; - $num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING]; - $num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN]; + if ($num_items_critical_alert > 0) { + return VISUAL_MAP_STATUS_CRITICAL_ALERT; + } else if ($num_items_critical > 0) { + return VISUAL_MAP_STATUS_CRITICAL_BAD; + } else if ($num_items_warning_alert > 0) { + return VISUAL_MAP_STATUS_WARNING_ALERT; + } else if ($num_items_warning > 0) { + return VISUAL_MAP_STATUS_WARNING; + } else if ($num_items_unknown > 0) { + return VISUAL_MAP_STATUS_UNKNOWN; + } else { + return VISUAL_MAP_STATUS_NORMAL; + } + break; + case 'weight': + $weight = $status_data['id_layout_linked_weight']; + $num_items = count($valid_layout_items); + $num_items_critical_alert = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]; + $num_items_critical = $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD]; + $num_items_warning_alert = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]; + $num_items_warning = $num_elements_by_status[VISUAL_MAP_STATUS_WARNING]; + $num_items_unknown = $num_elements_by_status[VISUAL_MAP_STATUS_UNKNOWN]; - if (($num_items_critical > 0 || $num_items_critical_alert > 0) - && ((($num_items_critical_alert + $num_items_critical) * 100) / $num_items) >= $weight - ) { - return ($num_items_critical_alert > 0) ? VISUAL_MAP_STATUS_CRITICAL_ALERT : VISUAL_MAP_STATUS_CRITICAL_BAD; - } else if (($num_items_warning > 0 || $num_items_warning_alert > 0) - && (($num_items_warning_alert + $num_items_warning * 100) / $num_items) >= $weight - ) { - return ($num_items_warning_alert > 0) ? VISUAL_MAP_STATUS_WARNING_ALERT : VISUAL_MAP_STATUS_WARNING; - } else if ($num_items_unknown > 0 - && (($num_items_unknown * 100) / $num_items) >= $weight - ) { - return VISUAL_MAP_STATUS_UNKNOWN; - } else { - return VISUAL_MAP_STATUS_NORMAL; - } - break; + if (($num_items_critical > 0 || $num_items_critical_alert > 0) + && ((($num_items_critical_alert + $num_items_critical) * 100) / $num_items) >= $weight + ) { + return ($num_items_critical_alert > 0) ? VISUAL_MAP_STATUS_CRITICAL_ALERT : VISUAL_MAP_STATUS_CRITICAL_BAD; + } else if (($num_items_warning > 0 || $num_items_warning_alert > 0) + && (($num_items_warning_alert + $num_items_warning * 100) / $num_items) >= $weight + ) { + return ($num_items_warning_alert > 0) ? VISUAL_MAP_STATUS_WARNING_ALERT : VISUAL_MAP_STATUS_WARNING; + } else if ($num_items_unknown > 0 + && (($num_items_unknown * 100) / $num_items) >= $weight + ) { + return VISUAL_MAP_STATUS_UNKNOWN; + } else { + return VISUAL_MAP_STATUS_NORMAL; + } + break; - case 'service': - $num_items_critical = ($num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD] + $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]); - $critical_percentage = (($num_items_critical * 100) / count($valid_layout_items)); + case 'service': + $num_items_critical = ($num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_BAD] + $num_elements_by_status[VISUAL_MAP_STATUS_CRITICAL_ALERT]); + $critical_percentage = (($num_items_critical * 100) / count($valid_layout_items)); - $num_items_warning = ($num_elements_by_status[VISUAL_MAP_STATUS_WARNING] + $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]); - $warning_percentage = (($num_items_warning * 100) / count($valid_layout_items)); + $num_items_warning = ($num_elements_by_status[VISUAL_MAP_STATUS_WARNING] + $num_elements_by_status[VISUAL_MAP_STATUS_WARNING_ALERT]); + $warning_percentage = (($num_items_warning * 100) / count($valid_layout_items)); - if ($critical_percentage >= $status_data['linked_layout_status_as_service_critical'] && $critical_percentage !== 0) { - return VISUAL_MAP_STATUS_CRITICAL_BAD; - } else if ($warning_percentage >= $status_data['linked_layout_status_as_service_warning'] && $warning_percentage !== 0) { - return VISUAL_MAP_STATUS_WARNING; - } else { - return VISUAL_MAP_STATUS_NORMAL; - } - break; + if ($critical_percentage >= $status_data['linked_layout_status_as_service_critical'] && $critical_percentage !== 0) { + return VISUAL_MAP_STATUS_CRITICAL_BAD; + } else if ($warning_percentage >= $status_data['linked_layout_status_as_service_warning'] && $warning_percentage !== 0) { + return VISUAL_MAP_STATUS_WARNING; + } else { + return VISUAL_MAP_STATUS_NORMAL; + } + break; + } } } diff --git a/pandora_console/include/graphs/functions_d3.php b/pandora_console/include/graphs/functions_d3.php index 8c4a1b6ade..e48babd58d 100644 --- a/pandora_console/include/graphs/functions_d3.php +++ b/pandora_console/include/graphs/functions_d3.php @@ -526,8 +526,7 @@ function print_clock_analogic_1( $color, $title=true ) { - global $config; - $output .= '