From 138fa636ad247a2d4e7817e07844a9fb309f5dd0 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 4 Jul 2023 11:06:49 +0200 Subject: [PATCH 1/7] #10637 Change group view --- pandora_console/include/styles/pandora.css | 4 + .../operation/agentes/group_view.php | 276 ++++++++++++++---- 2 files changed, 230 insertions(+), 50 deletions(-) diff --git a/pandora_console/include/styles/pandora.css b/pandora_console/include/styles/pandora.css index 06a3640c7c..c94cf12660 100644 --- a/pandora_console/include/styles/pandora.css +++ b/pandora_console/include/styles/pandora.css @@ -12289,3 +12289,7 @@ tr[id^="network_component-plugin-wmi-fields-dynamicMacroRow-"] input, tr[id^="network_component-plugin-snmp-fields-dynamicMacroRow-"] input { width: 100% !important; } + +.group_view_table > tbody > tr > td { + width: 350px !important; +} diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 34c3fc6936..204f7d937e 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -8,7 +8,7 @@ * @version 1.0.0 * @license See below * - * ______ ___ _______ _______ ________ + * ______ ___ _______ _______ ________ * | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __| * | __/| _ | | _ || _ | _| _ | | ___| |__ | * |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______| @@ -175,7 +175,182 @@ if ($total_agentes > 0) { $total_not_init = format_numeric((($agents_notinit * 100) / $total_agentes), 2); } -echo ''; +$all_group_id = []; +foreach ($result_groups as $group) { + if ($group['_id_'] !== '0') { + $all_group_id[] = $group['_id_']; + } +} + +$out = ''; +$out .= '
'; +$out .= ''; +$out .= ''; +$out .= ''; +$out .= ''; +$out .= ''; +$out .= ''; +$out .= ''; + +$description = ''; +$odd = false; +$graph_width = 180; +$graph_height = 200; + +foreach ($result_groups as $group) { + if ($group['_id_'] !== '0') { + $description = db_get_value('description', 'tgrupo', 'id_grupo', $group['_id_']); + $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group['_id_']); + $icon = html_print_image( + 'images/'.$icon_url, + true, + [ + 'title' => $group['_name_'], + 'class' => 'main_menu_icon invert_filter', + ] + ); + + $where_event = 'WHERE te.id_grupo = '.$group['_id_']; + $where_os = 'WHERE ta.id_grupo = '.$group['_id_']; + } else { + $description = __('Data view of all groups'); + $icon = ''; + $where_event = 'WHERE te.id_grupo in ('.implode(', ', $all_group_id).')'; + $where_os = 'WHERE ta.id_grupo in ('.implode(', ', $all_group_id).')'; + } + + $group_events = db_get_all_rows_sql( + 'SELECT COUNT(te.id_evento) as count_events, ta.alias + FROM tevento as te + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente '.$where_event.' GROUP BY te.id_agente' + ); + + $group_os = db_get_all_rows_sql( + 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo + FROM tconfig_os as os + INNER JOIN tagente as ta ON ta.id_os = os.id_os '.$where_os.' GROUP by os.name' + ); + + if ($odd === false) { + $out .= ''; + } + + $out .= ''; + $out .= ''; + + if ($odd === true) { + $out .= ''; + $odd = false; + } else { + $odd = true; + } +} + +$out .= ''; +$out .= ''; +$out .= ''; +$out .= '
'.__('Summary of the status groups').'
'; + $out .= '
+ '.$group['_name_'].'   '.$icon.''; + + $out .= ''; + $out .= ''; + $out .= ''; + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
+
+ '.__('Description').''.$description.'
+
'; + if ($group['_id_'] === '0') { + $out .= tactical_groups_get_stats_alerts($all_group_id); + } else { + $out .= tactical_groups_get_stats_alerts($group['_id_']); + } + + $out .= '
'; + if ($group['_id_'] === '0') { + $out .= tactical_groups_get_agents_and_monitoring($all_group_id); + } else { + $out .= tactical_groups_get_agents_and_monitoring($group['_id_']); + } + + $out .= ''; + if ($group['_id_'] === '0') { + $out .= groups_get_stats_modules_status($all_group_id); + } else { + $out .= groups_get_stats_modules_status($group['_id_']); + } + + $out .= '
'.__('Events per agent').''; + + $data = []; + $options = []; + $labels = []; + foreach ($group_events as $value) { + $data[$value['alias']] = $value['count_events']; + $labels[] = io_safe_output($value['alias']); + } + + $options = [ + 'width' => $graph_width, + 'height' => $graph_height, + 'legend' => ['display' => false], + 'labels' => $labels, + ]; + + $out .= '
'.'
'.pie_graph($data, $options).'
'; + $out .= '
'; + $out .= '
'.__('Distribution by so').''; + + $data = []; + $options = []; + $labels = []; + foreach ($group_os as $value) { + $data[$value['name_os']] = $value['count_os']; + $labels[] = io_safe_output($value['name_os']); + } + + $options = [ + 'width' => $graph_width, + 'height' => $graph_height, + 'legend' => ['display' => false], + 'labels' => $labels, + ]; + + $out .= '
'.'
'.pie_graph($data, $options).'
'; + $out .= '
'; + $out .= '
'; + + if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) { + $out .= ''.html_print_image( + 'images/force@svg.svg', + true, + [ + 'border' => '0', + 'title' => __('Force'), + 'class' => 'main_menu_icon invert_filter', + ] + ).''; + } + + $out .= '
'; + $out .= '
'; + $out .= '
'; + +echo $out; +/* + echo ''; echo ''; echo ''; echo "'; @@ -203,15 +378,15 @@ echo '
".__('Summary of the status groups').'
'; echo ''; echo ''; echo ''; -echo '
'; + echo ''; -if ($count == 1) { + if ($count == 1) { if ($result_groups[0]['_id_'] == 0) { unset($result_groups[0]); } -} + } -if (empty($result_groups) === false) { + if (empty($result_groups) === false) { $pagination = ui_pagination( $count, false, @@ -359,10 +534,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_']."'>"; } else { - $link = ""; + $link = ""; } if ($data['_id_'] == 0) { @@ -379,10 +554,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_UNKNOWN."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_unknown != 0)) { @@ -399,10 +574,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NOT_INIT."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_notinit != 0)) { @@ -419,10 +594,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NORMAL."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_ok != 0)) { @@ -439,10 +614,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_WARNING."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_warning != 0)) { @@ -459,10 +634,10 @@ if (empty($result_groups) === false) { echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_CRITICAL."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_critical != 0)) { @@ -478,11 +653,11 @@ if (empty($result_groups) === false) { // Monitors unknown echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_unknown != 0)) { @@ -498,11 +673,11 @@ if (empty($result_groups) === false) { // Monitors not init echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_not_init != 0)) { @@ -518,11 +693,11 @@ if (empty($result_groups) === false) { // Monitors OK echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_ok != 0)) { @@ -538,11 +713,11 @@ if (empty($result_groups) === false) { // Monitors Warning echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_warning != 0)) { @@ -558,11 +733,11 @@ if (empty($result_groups) === false) { // Monitors Critical echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_critical != 0)) { @@ -578,11 +753,11 @@ if (empty($result_groups) === false) { // Alerts fired echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($all_alerts_fired != 0)) { @@ -599,6 +774,7 @@ if (empty($result_groups) === false) { } echo ''; -} else { + } else { ui_print_info_message(__('There are no defined agents')); -} + } +*/ From 4d500b98e4a7fc4046edfe58ab839be1c95d05b6 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 22 Aug 2023 13:04:31 +0200 Subject: [PATCH 2/7] #10637 Change group report view --- .../include/functions_reporting_html.php | 117 +++++++++++++++++- 1 file changed, 114 insertions(+), 3 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 91d8a9e5a5..7c01e34515 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2581,7 +2581,118 @@ function reporting_html_group_report($table, $item, $pdf=0) $table->colspan['group_report']['cell'] = 3; $table->cellstyle['group_report']['cell'] = 'text-align: center;'; - $data = " + + $group_id = db_get_value('id_grupo', 'tgrupo', 'nombre', $item['subtitle']); + $description = db_get_value('description', 'tgrupo', 'id_grupo', $group_id); + $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group_id); + $icon = html_print_image( + 'images/'.$icon_url, + true, + [ + 'title' => $item['subtitle'], + 'class' => 'main_menu_icon invert_filter', + ] + ); + + $group_events = db_get_all_rows_sql( + 'SELECT COUNT(te.id_evento) as count_events, ta.alias + FROM tevento as te + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo = '.$group_id.' + GROUP BY te.id_agente' + ); + + $group_os = db_get_all_rows_sql( + 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo + FROM tconfig_os as os + INNER JOIN tagente as ta ON ta.id_os = os.id_os WHERE ta.id_grupo = '.$group_id.' GROUP by os.name' + ); + + $graph_width = 180; + $graph_height = 200; + + $out = '
'; + $out .= ''; + $out .= ''; + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
'; + $out .= '
+ '.$item['subtitle'].'   '.$icon.''; + + $out .= ''; + $out .= ''; + $out .= ''; + + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= ''; + $out .= '
+
+ '.__('Description').''.$description.'
+
'; + $out .= tactical_groups_get_stats_alerts($group_id); + $out .= '
'; + $out .= tactical_groups_get_agents_and_monitoring($group_id); + $out .= ''; + $out .= groups_get_stats_modules_status($group_id); + $out .= '
'.__('Events per agent').''; + $data = []; + $options = []; + $labels = []; + + foreach ($group_events as $value) { + $data[$value['alias']] = $value['count_events']; + $labels[] = io_safe_output($value['alias']); + } + + $options = [ + 'width' => $graph_width, + 'height' => $graph_height, + 'legend' => ['display' => false], + 'labels' => $labels, + ]; + + $out .= '
'.pie_graph($data, $options).'
'; + $out .= '
'; + $out .= '
'.__('Distribution by OS').''; + + $data = []; + $options = []; + $labels = []; + foreach ($group_os as $value) { + $data[$value['name_os']] = $value['count_os']; + $labels[] = io_safe_output($value['name_os']); + } + + $options = [ + 'width' => $graph_width, + 'height' => $graph_height, + 'legend' => ['display' => false], + 'labels' => $labels, + ]; + + $out .= '
'.pie_graph($data, $options).'
'; + $out .= '
'; + $out .= '
'; + + $out .= '
'; + $out .= '
'; + $out .= '
'; + + /* + $data = " @@ -2624,9 +2735,9 @@ function reporting_html_group_report($table, $item, $pdf=0) -
".__('Total')."".__('Events (not validated)')." ".$item['data']['count_events'].'
'; + ';*/ - $table->data['group_report']['cell'] = $data; + $table->data['group_report']['cell'] = $out; if ($pdf !== 0) { return $data; From 330f36a3cf4f71406071cf52d4d3b0059f72529c Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 22 Aug 2023 13:23:17 +0200 Subject: [PATCH 3/7] Fix group view --- .../operation/agentes/group_view.php | 274 ++++-------------- 1 file changed, 49 insertions(+), 225 deletions(-) diff --git a/pandora_console/operation/agentes/group_view.php b/pandora_console/operation/agentes/group_view.php index 204f7d937e..08066014e0 100644 --- a/pandora_console/operation/agentes/group_view.php +++ b/pandora_console/operation/agentes/group_view.php @@ -175,182 +175,7 @@ if ($total_agentes > 0) { $total_not_init = format_numeric((($agents_notinit * 100) / $total_agentes), 2); } -$all_group_id = []; -foreach ($result_groups as $group) { - if ($group['_id_'] !== '0') { - $all_group_id[] = $group['_id_']; - } -} - -$out = ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; -$out .= ''; - -$description = ''; -$odd = false; -$graph_width = 180; -$graph_height = 200; - -foreach ($result_groups as $group) { - if ($group['_id_'] !== '0') { - $description = db_get_value('description', 'tgrupo', 'id_grupo', $group['_id_']); - $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group['_id_']); - $icon = html_print_image( - 'images/'.$icon_url, - true, - [ - 'title' => $group['_name_'], - 'class' => 'main_menu_icon invert_filter', - ] - ); - - $where_event = 'WHERE te.id_grupo = '.$group['_id_']; - $where_os = 'WHERE ta.id_grupo = '.$group['_id_']; - } else { - $description = __('Data view of all groups'); - $icon = ''; - $where_event = 'WHERE te.id_grupo in ('.implode(', ', $all_group_id).')'; - $where_os = 'WHERE ta.id_grupo in ('.implode(', ', $all_group_id).')'; - } - - $group_events = db_get_all_rows_sql( - 'SELECT COUNT(te.id_evento) as count_events, ta.alias - FROM tevento as te - INNER JOIN tagente as ta ON te.id_agente = ta.id_agente '.$where_event.' GROUP BY te.id_agente' - ); - - $group_os = db_get_all_rows_sql( - 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo - FROM tconfig_os as os - INNER JOIN tagente as ta ON ta.id_os = os.id_os '.$where_os.' GROUP by os.name' - ); - - if ($odd === false) { - $out .= ''; - } - - $out .= ''; - $out .= ''; - - if ($odd === true) { - $out .= ''; - $odd = false; - } else { - $odd = true; - } -} - -$out .= ''; -$out .= ''; -$out .= ''; -$out .= '
'.__('Summary of the status groups').'
'; - $out .= '
- '.$group['_name_'].'   '.$icon.''; - - $out .= ''; - $out .= ''; - $out .= ''; - - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= ''; - $out .= '
-
- '.__('Description').''.$description.'
-
'; - if ($group['_id_'] === '0') { - $out .= tactical_groups_get_stats_alerts($all_group_id); - } else { - $out .= tactical_groups_get_stats_alerts($group['_id_']); - } - - $out .= '
'; - if ($group['_id_'] === '0') { - $out .= tactical_groups_get_agents_and_monitoring($all_group_id); - } else { - $out .= tactical_groups_get_agents_and_monitoring($group['_id_']); - } - - $out .= ''; - if ($group['_id_'] === '0') { - $out .= groups_get_stats_modules_status($all_group_id); - } else { - $out .= groups_get_stats_modules_status($group['_id_']); - } - - $out .= '
'.__('Events per agent').''; - - $data = []; - $options = []; - $labels = []; - foreach ($group_events as $value) { - $data[$value['alias']] = $value['count_events']; - $labels[] = io_safe_output($value['alias']); - } - - $options = [ - 'width' => $graph_width, - 'height' => $graph_height, - 'legend' => ['display' => false], - 'labels' => $labels, - ]; - - $out .= '
'.'
'.pie_graph($data, $options).'
'; - $out .= '
'; - $out .= '
'.__('Distribution by so').''; - - $data = []; - $options = []; - $labels = []; - foreach ($group_os as $value) { - $data[$value['name_os']] = $value['count_os']; - $labels[] = io_safe_output($value['name_os']); - } - - $options = [ - 'width' => $graph_width, - 'height' => $graph_height, - 'legend' => ['display' => false], - 'labels' => $labels, - ]; - - $out .= '
'.'
'.pie_graph($data, $options).'
'; - $out .= '
'; - $out .= '
'; - - if (!isset($data['_is_tag_']) && check_acl($config['id_user'], $data['_id_'], 'AW')) { - $out .= ''.html_print_image( - 'images/force@svg.svg', - true, - [ - 'border' => '0', - 'title' => __('Force'), - 'class' => 'main_menu_icon invert_filter', - ] - ).''; - } - - $out .= '
'; - $out .= '
'; - $out .= '
'; - -echo $out; -/* - echo ''; +echo '
'; echo ''; echo ''; echo "'; @@ -378,15 +203,15 @@ echo $out; echo ''; echo ''; echo ''; - echo '
".__('Summary of the status groups').'
'; +echo ''; - if ($count == 1) { +if ($count == 1) { if ($result_groups[0]['_id_'] == 0) { unset($result_groups[0]); } - } +} - if (empty($result_groups) === false) { +if (empty($result_groups) === false) { $pagination = ui_pagination( $count, false, @@ -534,10 +359,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = "
"; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_']."'>"; } else { - $link = ""; + $link = ""; } if ($data['_id_'] == 0) { @@ -554,10 +379,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_UNKNOWN."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_unknown != 0)) { @@ -574,10 +399,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NOT_INIT."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_notinit != 0)) { @@ -594,10 +419,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_NORMAL."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_ok != 0)) { @@ -614,10 +439,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_WARNING."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_warning != 0)) { @@ -634,10 +459,10 @@ echo $out; echo ""; if (isset($data['_is_tag_'])) { $link = ""; + href='index.php?sec=monitoring&sec2=operation/tree&tag_id=".$data['_id_'].'&status='.AGENT_STATUS_CRITICAL."'>"; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($agents_critical != 0)) { @@ -653,11 +478,11 @@ echo $out; // Monitors unknown echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_unknown != 0)) { @@ -673,11 +498,11 @@ echo $out; // Monitors not init echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_not_init != 0)) { @@ -693,11 +518,11 @@ echo $out; // Monitors OK echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_ok != 0)) { @@ -713,11 +538,11 @@ echo $out; // Monitors Warning echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_warning != 0)) { @@ -733,11 +558,11 @@ echo $out; // Monitors Critical echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($monitor_critical != 0)) { @@ -753,11 +578,11 @@ echo $out; // Alerts fired echo ""; if (!isset($data['_is_tag_'])) { - $link = ""; + $link = ""; } else { - $link = ""; + $link = ""; } if (($data['_id_'] == 0) && ($all_alerts_fired != 0)) { @@ -774,7 +599,6 @@ echo $out; } echo ''; - } else { +} else { ui_print_info_message(__('There are no defined agents')); - } -*/ +} From fa2d3ec2e50af3df06bd0107593932d4a522a23d Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Tue, 22 Aug 2023 15:03:12 +0200 Subject: [PATCH 4/7] #10637 Fix all group view --- .../include/functions_reporting_html.php | 71 +++++++++++++------ 1 file changed, 48 insertions(+), 23 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 7c01e34515..8b4473436d 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2582,30 +2582,55 @@ function reporting_html_group_report($table, $item, $pdf=0) $table->colspan['group_report']['cell'] = 3; $table->cellstyle['group_report']['cell'] = 'text-align: center;'; - $group_id = db_get_value('id_grupo', 'tgrupo', 'nombre', $item['subtitle']); - $description = db_get_value('description', 'tgrupo', 'id_grupo', $group_id); - $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group_id); - $icon = html_print_image( - 'images/'.$icon_url, - true, - [ - 'title' => $item['subtitle'], - 'class' => 'main_menu_icon invert_filter', - ] - ); + if ($item['subtitle'] === 'All') { + $group_id = []; + $all_group_id = db_get_all_rows_sql('SELECT id_grupo FROM tgrupo'); - $group_events = db_get_all_rows_sql( - 'SELECT COUNT(te.id_evento) as count_events, ta.alias - FROM tevento as te - INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo = '.$group_id.' - GROUP BY te.id_agente' - ); + foreach ($all_group_id as $group) { + $group_id[] = $group['id_grupo']; + } - $group_os = db_get_all_rows_sql( - 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo - FROM tconfig_os as os - INNER JOIN tagente as ta ON ta.id_os = os.id_os WHERE ta.id_grupo = '.$group_id.' GROUP by os.name' - ); + $description = __('Data view of all groups'); + $icon = ''; + + $group_events = db_get_all_rows_sql( + 'SELECT COUNT(te.id_evento) as count_events, ta.alias + FROM tevento as te + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente + GROUP BY te.id_agente' + ); + + $group_os = db_get_all_rows_sql( + 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo + FROM tconfig_os as os + INNER JOIN tagente as ta ON ta.id_os = os.id_os GROUP by os.name' + ); + } else { + $group_id = db_get_value('id_grupo', 'tgrupo', 'nombre', $item['subtitle']); + $description = db_get_value('description', 'tgrupo', 'id_grupo', $group_id); + $icon_url = db_get_value('icon', 'tgrupo', 'id_grupo', $group_id); + $icon = html_print_image( + 'images/'.$icon_url, + true, + [ + 'title' => $item['subtitle'], + 'class' => 'main_menu_icon invert_filter', + ] + ); + + $group_events = db_get_all_rows_sql( + 'SELECT COUNT(te.id_evento) as count_events, ta.alias + FROM tevento as te + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo = '.$group_id.' + GROUP BY te.id_agente' + ); + + $group_os = db_get_all_rows_sql( + 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo + FROM tconfig_os as os + INNER JOIN tagente as ta ON ta.id_os = os.id_os WHERE ta.id_grupo = '.$group_id.' GROUP by os.name' + ); + } $graph_width = 180; $graph_height = 200; @@ -2622,7 +2647,7 @@ function reporting_html_group_report($table, $item, $pdf=0) $out .= ''; $out .= '
- '.__('Description').''.$description.'
+ '.__('Group Description').''.$description.' '; $out .= ''; From 34bbc5f0de9fa5bd8c1b78a8c97b61aa2f5eb86f Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Wed, 23 Aug 2023 11:48:39 +0200 Subject: [PATCH 5/7] #10637 Fix recursive group --- .../include/functions_reporting_html.php | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 8b4473436d..4ee1cb98b3 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2618,17 +2618,34 @@ function reporting_html_group_report($table, $item, $pdf=0) ] ); + $childrens = db_get_all_rows_sql('SELECT id_grupo FROM tgrupo WHERE parent = '.$group_id); + $total_agents = db_get_all_rows_sql('SELECT COUNT(id_agente) as total FROM tagente where id_grupo = '.$group_id); + + if ($childrens !== false && (int) $total_agents[0]['total'] !== $item['data']['group_stats']['total_agents']) { + $array_group_id = []; + $array_group_id[] = $group_id; + foreach ($childrens as $group) { + $array_group_id[] = $group['id_grupo']; + } + + $group_id = $array_group_id; + $explode_group_id = implode(',', $group_id); + } else { + $explode_group_id = $group_id; + } + $group_events = db_get_all_rows_sql( 'SELECT COUNT(te.id_evento) as count_events, ta.alias FROM tevento as te - INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo = '.$group_id.' + INNER JOIN tagente as ta ON te.id_agente = ta.id_agente WHERE te.id_grupo IN ('.$explode_group_id.') GROUP BY te.id_agente' ); $group_os = db_get_all_rows_sql( 'SELECT COUNT(os.name) as count_os, os.name as name_os, ta.id_grupo FROM tconfig_os as os - INNER JOIN tagente as ta ON ta.id_os = os.id_os WHERE ta.id_grupo = '.$group_id.' GROUP by os.name' + INNER JOIN tagente as ta ON ta.id_os = os.id_os + WHERE ta.id_grupo IN ('.$explode_group_id.') GROUP by os.name' ); } From aba22003b3791aacb93550ea0f9e229c986abc33 Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 24 Aug 2023 09:47:03 +0200 Subject: [PATCH 6/7] #10637 Fix PDF --- .../include/functions_reporting_html.php | 56 +++++++++++++++++-- 1 file changed, 51 insertions(+), 5 deletions(-) diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 4ee1cb98b3..034765c1bc 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2649,8 +2649,8 @@ function reporting_html_group_report($table, $item, $pdf=0) ); } - $graph_width = 180; - $graph_height = 200; + $graph_width = 280; + $graph_height = 250; $out = ''; $out .= ''; @@ -2691,14 +2691,40 @@ function reporting_html_group_report($table, $item, $pdf=0) $labels[] = io_safe_output($value['alias']); } + if ($pdf !== 0) { + $ttl = 2; + } else { + $ttl = 0; + } + $options = [ 'width' => $graph_width, 'height' => $graph_height, 'legend' => ['display' => false], 'labels' => $labels, + 'ttl' => $ttl, + 'legend' => [ + 'display' => true, + 'position' => 'top', + 'align' => 'center', + ], ]; - $out .= '
'.pie_graph($data, $options).'
'; + $out .= '
'; + if ((int) $ttl === 2) { + $out .= ''; + } + + $out .= pie_graph($data, $options); + if ((int) $ttl === 2) { + $out .= '" />'; + } else { + $out .= '
'; + } + + $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; @@ -2782,7 +2828,7 @@ function reporting_html_group_report($table, $item, $pdf=0) $table->data['group_report']['cell'] = $out; if ($pdf !== 0) { - return $data; + return $out; } } From 6a4e8e9a92179577f7493e7697dcdc120cf23aaf Mon Sep 17 00:00:00 2001 From: miguel angel rasteu Date: Thu, 24 Aug 2023 14:58:30 +0200 Subject: [PATCH 7/7] #10637 Fix group view --- pandora_console/include/functions_groups.php | 44 +++++++++++-------- .../include/functions_reporting_html.php | 41 ++++++++++++++--- 2 files changed, 61 insertions(+), 24 deletions(-) diff --git a/pandora_console/include/functions_groups.php b/pandora_console/include/functions_groups.php index 3b659a30e8..0be3a8dffe 100644 --- a/pandora_console/include/functions_groups.php +++ b/pandora_console/include/functions_groups.php @@ -2648,14 +2648,16 @@ function groups_get_heat_map_agents(array $id_group, float $width=0, float $heig * * @return string Html */ -function tactical_groups_get_agents_and_monitoring($id_groups) +function tactical_groups_get_agents_and_monitoring($id_groups, $data='') { global $config; - $data = [ - 'total_agents' => groups_agents_total_counters($id_groups, false)['total'], - 'monitor_total' => groups_get_total_monitors($id_groups, [], [], false, false, false, false), - ]; + if ($data === '') { + $data = [ + 'total_agents' => groups_agents_total_counters($id_groups, false)['total'], + 'monitor_total' => groups_get_total_monitors($id_groups, [], [], false, false, false, false), + ]; + } // Link URLS $urls = []; @@ -2703,16 +2705,18 @@ function tactical_groups_get_agents_and_monitoring($id_groups) * @param [type] $id_groups * @return string Html. */ -function tactical_groups_get_stats_alerts($id_groups) +function tactical_groups_get_stats_alerts($id_groups, $data='') { global $config; - $alerts = groups_monitor_alerts_total_counters($id_groups, false); - $data = [ - 'monitor_alerts' => $alerts['total'], - 'monitor_alerts_fired' => $alerts['fired'], + if ($data === '') { + $alerts = groups_monitor_alerts_total_counters($id_groups, false); + $data = [ + 'monitor_alerts' => $alerts['total'], + 'monitor_alerts_fired' => $alerts['fired'], - ]; + ]; + } $urls = []; $urls['monitor_alerts'] = $config['homeurl'].'index.php?sec=estado&sec2=operation/agentes/alerts_status&refr=60&ag_group='.$id_groups[0]; @@ -2780,17 +2784,19 @@ function tactical_groups_get_stats_alerts($id_groups) * @param boolean $data_agents * @return void */ -function groups_get_stats_modules_status($id_groups, $graph_width=250, $graph_height=150, $links=false, $data_agents=false) +function groups_get_stats_modules_status($id_groups, $graph_width=250, $graph_height=150, $links=false, $data_agents=false, $data='') { global $config; - $data = [ - 'monitor_critical' => groups_get_critical_monitors($id_groups, [], [], false, false, false, false), - 'monitor_warning' => groups_get_warning_monitors($id_groups, [], [], false, false, false, false), - 'monitor_ok' => groups_get_normal_monitors($id_groups, [], [], false, false, false, false), - 'monitor_unknown' => groups_get_unknown_monitors($id_groups, [], [], false, false, false, false), - 'monitor_not_init' => groups_get_not_init_monitors($id_groups, [], [], false, false, false, false), - ]; + if ($data === '') { + $data = [ + 'monitor_critical' => groups_get_critical_monitors($id_groups, [], [], false, false, false, false), + 'monitor_warning' => groups_get_warning_monitors($id_groups, [], [], false, false, false, false), + 'monitor_ok' => groups_get_normal_monitors($id_groups, [], [], false, false, false, false), + 'monitor_unknown' => groups_get_unknown_monitors($id_groups, [], [], false, false, false, false), + 'monitor_not_init' => groups_get_not_init_monitors($id_groups, [], [], false, false, false, false), + ]; + } // Link URLS. if ($links === false) { diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 034765c1bc..eb7c555fb9 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -2581,6 +2581,13 @@ function reporting_html_group_report($table, $item, $pdf=0) $table->colspan['group_report']['cell'] = 3; $table->cellstyle['group_report']['cell'] = 'text-align: center;'; + $metaconsole_connected = false; + if (is_metaconsole() === true) { + $connection = metaconsole_get_connection($item['server_name']); + if (metaconsole_connect($connection) == NOERR) { + $metaconsole_connected = true; + } + } if ($item['subtitle'] === 'All') { $group_id = []; @@ -2649,6 +2656,10 @@ function reporting_html_group_report($table, $item, $pdf=0) ); } + if ($metaconsole_connected === true) { + metaconsole_restore_db(); + } + $graph_width = 280; $graph_height = 250; @@ -2664,19 +2675,39 @@ function reporting_html_group_report($table, $item, $pdf=0) $out .= ''; $out .= ''; - $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= ''; $out .= '';
'.__('Distribution by OS').''; @@ -2716,9 +2742,29 @@ function reporting_html_group_report($table, $item, $pdf=0) 'height' => $graph_height, 'legend' => ['display' => false], 'labels' => $labels, + 'ttl' => $ttl, + 'legend' => [ + 'display' => true, + 'position' => 'top', + 'align' => 'center', + ], ]; - $out .= '
'.pie_graph($data, $options).'
'; + $out .= '
'; + if ((int) $ttl === 2) { + $out .= ''; + } + + $out .= pie_graph($data, $options); + if ((int) $ttl === 2) { + $out .= '" />'; + } else { + $out .= '
'; + } + + $out .= ''; $out .= '
'; $out .= '
- '.__('Group Description').''.$description.'
+ '.__('Group Description').'  '.$description.'
'; - $out .= tactical_groups_get_stats_alerts($group_id); + + $data = [ + 'monitor_alerts' => $item['data']['group_stats']['monitor_alerts'], + 'monitor_alerts_fired' => $item['data']['group_stats']['monitor_alerts_fired'], + + ]; + + $out .= tactical_groups_get_stats_alerts($group_id, $data); $out .= '
'; - $out .= tactical_groups_get_agents_and_monitoring($group_id); + + $data = [ + 'total_agents' => $item['data']['group_stats']['total_agents'], + 'monitor_total' => $item['data']['group_stats']['monitor_checks'], + ]; + + $out .= tactical_groups_get_agents_and_monitoring($group_id, $data); $out .= ''; - $out .= groups_get_stats_modules_status($group_id); + + $data = [ + 'monitor_critical' => $item['data']['group_stats']['monitor_critical'], + 'monitor_warning' => $item['data']['group_stats']['monitor_warning'], + 'monitor_ok' => $item['data']['group_stats']['monitor_ok'], + 'monitor_unknown' => $item['data']['group_stats']['monitor_unknown'], + 'monitor_not_init' => $item['data']['group_stats']['monitor_not_init'], + ]; + $out .= groups_get_stats_modules_status($group_id, 250, 150, false, false, $data); $out .= '