diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index ca74b7d171..de08a299de 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -1387,7 +1387,7 @@ $table_advanced->data['made_enabled'][0] = html_print_checkbox_switch( 'made_enabled', 1, (bool) $made_enabled, - false, + true, false, '', false, diff --git a/pandora_console/godmode/setup/setup_visuals.php b/pandora_console/godmode/setup/setup_visuals.php index 6379f86d3a..4336da55b9 100755 --- a/pandora_console/godmode/setup/setup_visuals.php +++ b/pandora_console/godmode/setup/setup_visuals.php @@ -2129,6 +2129,15 @@ $table_other->data[$row][] = html_print_label_input_block( __('Data multiplier to use in graphs/data'), html_print_select($options_data_multiplier, 'use_data_multiplier', $config['use_data_multiplier'], '', '', 1, true, false, false) ); +$table_other->data[$row][] = html_print_label_input_block( + __('Disable general statistics in main tactical view'), + html_print_checkbox_switch( + 'disable_general_statistics', + 1, + $config['disable_general_statistics'], + true + ) +); $row++; /* diff --git a/pandora_console/include/functions_config.php b/pandora_console/include/functions_config.php index 1fe38aac0b..a09e3f1706 100644 --- a/pandora_console/include/functions_config.php +++ b/pandora_console/include/functions_config.php @@ -1568,6 +1568,10 @@ function config_update_config() $error_update[] = __('Use data multiplier'); } + if (config_update_value('disable_general_statistics', get_parameter('disable_general_statistics', 0), true) === false) { + $error_update[] = __('Disable general statistics'); + } + if (config_update_value('decimal_separator', (string) get_parameter('decimal_separator', '.'), true) === false) { $error_update[] = __('Decimal separator'); } else { @@ -3703,6 +3707,10 @@ function config_process_config() config_update_value('use_data_multiplier', '1'); } + if (!isset($config['disable_general_statistics'])) { + config_update_value('disable_general_statistics', 0); + } + if (!isset($config['command_snapshot'])) { config_update_value('command_snapshot', 1); } diff --git a/pandora_console/include/functions_graph.php b/pandora_console/include/functions_graph.php index 3ba76b17d0..d1c31f95b0 100644 --- a/pandora_console/include/functions_graph.php +++ b/pandora_console/include/functions_graph.php @@ -27,6 +27,8 @@ * ============================================================================ */ +use Models\VisualConsole\Items\Percentile; + require_once $config['homedir'].'/include/graphs/fgraph.php'; require_once $config['homedir'].'/include/functions_reporting.php'; require_once $config['homedir'].'/include/functions_agents.php'; @@ -2686,7 +2688,9 @@ function graph_agent_status( $return=false, $show_not_init=false, $data_agents=false, - $donut_narrow_graph=false + $donut_narrow_graph=false, + $onClick='', + $data_in_percentage=false, ) { global $config; @@ -2766,6 +2770,25 @@ function graph_agent_status( 'labels' => array_keys($data), ]; + if (empty($onClick) === false) { + $options['onClick'] = $onClick; + } + + if ($data_in_percentage === true) { + $percentages = []; + $total = array_sum($data); + foreach ($data as $key => $value) { + $percentage = (($value / $total) * 100); + if ($percentage < 1 && $percentage > 0) { + $percentage = 1; + } + + $percentages[$key] = format_numeric($percentage, 0); + } + + $data = $percentages; + } + if ($donut_narrow_graph == true) { $out = ring_graph( $data, @@ -4625,9 +4648,15 @@ function graph_nodata_image($options) return base64_encode($dataImg); } - $widthImage = '200px'; + $style = ''; if (isset($options['nodata_image']['width']) === true) { - $widthImage = $options['nodata_image']['width']; + $style .= 'width: '.$options['nodata_image']['width'].'; '; + } else { + $style .= 'width: 200px; '; + } + + if (isset($options['nodata_image']['height']) === true) { + $style .= 'height: '.$options['nodata_image']['height'].'; '; } return html_print_image( @@ -4635,7 +4664,7 @@ function graph_nodata_image($options) true, [ 'title' => __('No data'), - 'style' => 'width: '.$widthImage.';', + 'style' => $style, ] ); } diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 5e5818357b..afb2154cfe 100644 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -669,6 +669,12 @@ function get_build_setup_charts($type, $options, $data) $chart->setId($id); + if (isset($options['onClick']) === true + && empty($options['onClick']) === false + ) { + $chart->options()->setOnClick($options['onClick']); + } + // Height is null maximum possible. if (isset($options['height']) === true && empty($options['height']) === false diff --git a/pandora_console/include/javascript/general_tactical_view.js b/pandora_console/include/javascript/general_tactical_view.js index b671c56103..5761f4b51f 100644 --- a/pandora_console/include/javascript/general_tactical_view.js +++ b/pandora_console/include/javascript/general_tactical_view.js @@ -73,8 +73,40 @@ $(document).ready(function() { $("#heatmap-title").html($(title).html()); } }); + rescaling(); + + $(window).on("resize", function() { + rescaling(); + }); }); +function showLabel(element, event, label) { + $(".label_heatmap").remove(); + const tooltip = $(document.createElement("div")); + tooltip.html(label); + tooltip.attr("class", "label_heatmap"); + $("#heatmap-group").append(tooltip); + var x = event.clientX; + var y = event.clientY; + tooltip.attr( + "style", + "position: fixed; top:" + (y + 15) + "px; left:" + (x + 20) + "px;" + ); +} + +function hideLabel() { + $(".label_heatmap").remove(); +} + +function rescaling() { + if (window.innerWidth < 1300) { + $(".trigger-100").attr("style", "width: 100%;"); + $(".trigger-100").addClass("br-b"); + } else { + $(".trigger-100").removeAttr("style"); + $(".trigger-100").removeClass("br-b"); + } +} function autoRefresh(interval, id, method, php_class) { setInterval(() => { $.ajax({ @@ -92,3 +124,108 @@ function autoRefresh(interval, id, method, php_class) { }); }, interval); } + +function redirectStatus(e, element) { + if (element.length > 0) { + switch (e.chart.legend.legendItems[element[0].index].text) { + case "Critical": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group=0&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status=1&sort_field=&sort=none&pure=` + ); + break; + + case "Warning": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group=0&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status=2&sort_field=&sort=none&pure=` + ); + break; + + case "Unknown": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group=0&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status=3&sort_field=&sort=none&pure=` + ); + break; + + case "Not init": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group=0&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status=5&sort_field=&sort=none&pure=` + ); + break; + + default: + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/status_monitor&refr=0&ag_group=0&ag_freestring=&module_option=1&ag_modulename=&moduletype=&datatype=&status=-1&sort_field=&sort=none&pure=` + ); + break; + } + } +} + +function redirectHeatmap(view, id, id_agente = 0) { + switch (view) { + case "group": + window.location.assign( + `index.php?sec=view&sec2=godmode/groups/tactical&id_group=${id}` + ); + break; + + case "agent": + window.location.assign( + `index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=${id}` + ); + break; + + case "module": + if (id_agente > 0) { + window.location.assign( + `index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&id_agente=${id_agente}&tab=module&id_agent_module=${id}&edit_module=1` + ); + } + break; + + default: + break; + } +} + +function redirectAgentStatus(e, element) { + if (element.length > 0) { + switch (e.chart.legend.legendItems[element[0].index].text) { + case "No monitors": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/estado_agente` + ); + break; + + case "CRITICAL": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/estado_agente&status=1` + ); + break; + + case "WARNING": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/estado_agente&status=2` + ); + break; + + case "UKNOWN": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/estado_agente&status=3` + ); + break; + + case "NORMAL": + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/estado_agente&status=0` + ); + break; + + default: + window.location.assign( + `index.php?sec=view&sec2=operation/agentes/estado_agente` + ); + break; + } + } +} diff --git a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php index 3bc2e45246..d61b748bca 100644 --- a/pandora_console/include/lib/TacticalView/GeneralTacticalView.php +++ b/pandora_console/include/lib/TacticalView/GeneralTacticalView.php @@ -50,6 +50,22 @@ class GeneralTacticalView } + /** + * Returns whether general statistics are disabled. + * + * @return boolean + */ + public function disableGeneralStatistics():bool + { + global $config; + if (users_is_admin($config['id_user']) === true) { + return false; + } else { + return (bool) $config['disable_general_statistics']; + } + } + + /** * Instantiate all the elements that will build the dashboard * @@ -109,6 +125,7 @@ class GeneralTacticalView { $data = []; $data['javascript'] = $this->javascript(); + $data['disableGeneralStatistics'] = $this->disableGeneralStatistics(); $data = array_merge($data, $this->elements); View::render( 'tacticalView/view', diff --git a/pandora_console/include/lib/TacticalView/elements/Agents.php b/pandora_console/include/lib/TacticalView/elements/Agents.php index 97063ec300..a0e14313e0 100644 --- a/pandora_console/include/lib/TacticalView/elements/Agents.php +++ b/pandora_console/include/lib/TacticalView/elements/Agents.php @@ -429,12 +429,29 @@ class Agents extends Element 'cutout' => 80, 'nodata_image' => ['width' => '80%'], 'colors' => $colors, + 'onClick' => 'redirectAgentStatus', ]; + + // To avoid that if a value is too small it is not seen. + $percentages = []; + $total = array_sum($data); + foreach ($data as $key => $value) { + $percentage = (($value / $total) * 100); + if ($percentage < 1 && $percentage > 0) { + $percentage = 1; + } + + $percentages[$key] = format_numeric($percentage, 0); + } + + $data = $percentages; + $pie = ring_graph($data, $options); $output = html_print_div( [ 'content' => $pie, 'style' => 'margin: 0 auto; max-width: 80%; max-height: 220px;', + 'class' => 'clickable', ], true ); diff --git a/pandora_console/include/lib/TacticalView/elements/Database.php b/pandora_console/include/lib/TacticalView/elements/Database.php index 21f8053163..4c0d3a5368 100644 --- a/pandora_console/include/lib/TacticalView/elements/Database.php +++ b/pandora_console/include/lib/TacticalView/elements/Database.php @@ -34,7 +34,9 @@ class Database extends Element */ public function __construct() { + global $config; parent::__construct(); + include_once $config['homedir'].'/include/graphs/fgraph.php'; $this->title = __('Database'); $this->ajaxMethods = [ 'getStatus', diff --git a/pandora_console/include/lib/TacticalView/elements/Events.php b/pandora_console/include/lib/TacticalView/elements/Events.php index a7f9970ee3..1c87f4cc9e 100644 --- a/pandora_console/include/lib/TacticalView/elements/Events.php +++ b/pandora_console/include/lib/TacticalView/elements/Events.php @@ -57,23 +57,13 @@ class Events extends Element { global $config; $id_groups = array_keys(users_get_groups($config['id_user'], 'AR', false)); - if (in_array(0, $id_groups) === false) { - foreach ($id_groups as $key => $id_group) { - if ((bool) check_acl_restricted_all($config['id_user'], $id_group, 'AR') === false) { - unset($id_groups[$key]); - } - } - } - - if (users_can_manage_group_all() === true) { - $id_groups[] = 0; - } - $id_groups = implode(',', $id_groups); $event_view_h = (int) ($config['event_view_hr'] > 24) ? 24 : $config['event_view_hr']; $time_events = ($event_view_h * 3600); $intervalh = (time() - $time_events); - $sql = 'SELECT utimestamp from tevento WHERE utimestamp >= '.$intervalh.' ORDER BY utimestamp DESC;'; + $sql = 'SELECT utimestamp + FROM tevento + WHERE utimestamp >= '.$intervalh.' AND id_grupo IN ('.$id_groups.') ORDER BY utimestamp DESC;'; $rows = db_process_sql($sql); $cut_seconds = ($time_events / 24); $now = (time() - 300); @@ -377,6 +367,13 @@ class Events extends Element $data = []; $colors = []; foreach ($rows as $key => $row) { + if ($row['criticity'] != EVENT_CRIT_CRITICAL + && $row['criticity'] != EVENT_CRIT_NORMAL + && $row['criticity'] != EVENT_CRIT_WARNING + ) { + continue; + } + switch ($row['criticity']) { case EVENT_CRIT_CRITICAL: $label = __('CRITICAL'); @@ -394,9 +391,7 @@ class Events extends Element break; default: - $colors[] = COL_UNKNOWN; - $label = __('UNKNOWN'); - break; + continue; } $labels[] = $this->controlSizeText($label); @@ -410,6 +405,21 @@ class Events extends Element 'nodata_image' => ['width' => '100%'], 'colors' => $colors, ]; + + // To avoid that if a value is too small it is not seen. + $percentages = []; + $total = array_sum($data); + foreach ($data as $key => $value) { + $percentage = (($value / $total) * 100); + if ($percentage < 1 && $percentage > 0) { + $percentage = 1; + } + + $percentages[$key] = format_numeric($percentage, 0); + } + + $data = $percentages; + $pie = ring_graph($data, $options); $output = html_print_div( [ @@ -448,9 +458,10 @@ class Events extends Element 'style' => 'width: 90%;', 'ajax_url' => 'operation/events/events', 'ajax_data' => [ - 'get_events' => 1, - 'compact_date' => 1, - 'external_url' => 1, + 'get_events' => 1, + 'compact_date' => 1, + 'external_url' => 1, + 'compact_name_event' => 1, ], 'order' => [ 'field' => 'timestamp', diff --git a/pandora_console/include/lib/TacticalView/elements/Groups.php b/pandora_console/include/lib/TacticalView/elements/Groups.php index 82b0f358b1..dfb40fb79d 100644 --- a/pandora_console/include/lib/TacticalView/elements/Groups.php +++ b/pandora_console/include/lib/TacticalView/elements/Groups.php @@ -118,7 +118,6 @@ class Groups extends Element return graph_nodata_image(['width' => '400']); } - $groups = $modules; // Best square. $high = (float) max($width, $height); $low = 0.0; @@ -147,7 +146,7 @@ class Groups extends Element $x = 0; $y = 0; $cont = 1; - foreach ($groups as $key => $value) { + foreach ($modules as $key => $value) { $module_id = $value['id_agente_modulo']; $db_status = modules_get_agentmodule_status($module_id); $module_value = modules_get_last_value($module_id); @@ -183,10 +182,16 @@ class Groups extends Element break; } + $redirect = ''; + if (check_acl($config['id_user'], 0, 'AW')) { + $redirect = 'onclick="redirectHeatmap(\'module\', '.$module_id.', '.$value['id_agente'].')"'; + } + $heatmap .= sprintf( - '', + '', 'rect_'.$cont, $x, + $value['nombre'], $y, $row, $column, @@ -350,9 +355,10 @@ class Groups extends Element } $heatmap .= sprintf( - '', + '', 'rect_'.$cont, $x, + $value['alias'], $y, $row, $column, @@ -490,9 +496,10 @@ class Groups extends Element } $heatmap .= sprintf( - '', + '', 'rect_'.$cont, $x, + $value['_name_'], $y, $row, $column, diff --git a/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php b/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php index eece06f65f..8a572219bd 100644 --- a/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php +++ b/pandora_console/include/lib/TacticalView/elements/MonitoringElements.php @@ -75,7 +75,10 @@ class MonitoringElements extends Element 'display' => false, ], 'cutout' => 80, - 'nodata_image' => ['width' => '100%'], + 'nodata_image' => [ + 'width' => '100%', + 'height' => '90%', + ], ]; $pie = ring_graph($data, $options); $output = html_print_div( @@ -139,7 +142,10 @@ class MonitoringElements extends Element 'display' => false, ], 'cutout' => 80, - 'nodata_image' => ['width' => '100%'], + 'nodata_image' => [ + 'width' => '100%', + 'height' => '90%', + ], ]; $pie = ring_graph($data, $options); $output = html_print_div( @@ -208,7 +214,10 @@ class MonitoringElements extends Element 'display' => false, ], 'cutout' => 80, - 'nodata_image' => ['width' => '100%'], + 'nodata_image' => [ + 'width' => '100%', + 'height' => '90%', + ], ]; $pie = ring_graph($data, $options); $output = html_print_div( @@ -230,11 +239,12 @@ class MonitoringElements extends Element */ public function getMonitoringStatusGraph():string { - $pie = graph_agent_status(false, '', '', true, true, false, true); + $pie = graph_agent_status(false, '', '', true, true, false, true, 'redirectStatus', true); $output = html_print_div( [ 'content' => $pie, 'style' => 'margin: 0 auto; max-width: 80%; max-height: 220px;', + 'class' => 'clickable', ], true ); diff --git a/pandora_console/include/lib/TacticalView/elements/Overview.php b/pandora_console/include/lib/TacticalView/elements/Overview.php index 1e9534b652..6234887e94 100644 --- a/pandora_console/include/lib/TacticalView/elements/Overview.php +++ b/pandora_console/include/lib/TacticalView/elements/Overview.php @@ -36,6 +36,7 @@ class Overview extends Element { global $config; parent::__construct(); + include_once $config['homedir'].'/include/graphs/fgraph.php'; if (is_ajax() === true) { include_once $config['homedir'].'/include/functions_servers.php'; } @@ -163,6 +164,9 @@ class Overview extends Element if ($info['limit'] > $info['count']) { $used = round(($info['count'] / $info['limit']) * 100); $free = (100 - $used); + } else if ($info['limit'] <= $info['count']) { + $free = 0; + $used = 100; } else { $free = 100; $used = 0; diff --git a/pandora_console/include/styles/general_tactical_view.css b/pandora_console/include/styles/general_tactical_view.css index 0a7f6bdd67..24997f8f17 100644 --- a/pandora_console/include/styles/general_tactical_view.css +++ b/pandora_console/include/styles/general_tactical_view.css @@ -23,11 +23,12 @@ align-items: stretch; } .col-12 { - width: 100%; + width: 99%; } .col-6, .col-xl-6 { width: 50%; + flex: 1; display: flex; flex-wrap: nowrap; flex-direction: column; @@ -58,6 +59,9 @@ border-radius: 10px; height: 100%; max-width: 100%; + display: flex; + flex-direction: column; + justify-content: flex-start; } .br-l { border-left: 1px solid #e5e9ed; @@ -325,6 +329,22 @@ table.dataTable thead th { background-color: #ec7176; } +#svg rect { + cursor: pointer; +} + +.trigger-100 { + display: flex; + flex-direction: column; +} +.label_heatmap { + position: absolute; + background-color: #757575; + color: white; + padding: 2px 5px; + border-radius: 5px; +} + @media (max-width: 1636px) { .col-xl-6 { width: 100%; @@ -344,9 +364,7 @@ table.dataTable thead th { .col-7 { width: 56%; } - .col-5 { - width: 41%; - } + .flex-nowrap { flex-wrap: nowrap !important; } diff --git a/pandora_console/operation/events/events.php b/pandora_console/operation/events/events.php index 4c3eae145e..86f8d43a27 100644 --- a/pandora_console/operation/events/events.php +++ b/pandora_console/operation/events/events.php @@ -342,6 +342,7 @@ if (is_ajax() === true) { $table_id = get_parameter('table_id', ''); $groupRecursion = (bool) get_parameter('groupRecursion', false); $compact_date = (int) get_parameter('compact_date', 0); + $compact_name_event = (int) get_parameter('compact_name_event', 0); // Datatables offset, limit. $start = (int) get_parameter('start', 0); @@ -471,7 +472,7 @@ if (is_ajax() === true) { $data = array_reduce( $events, - function ($carry, $item) use ($table_id, &$redirection_form_id, $filter, $compact_date, $external_url) { + function ($carry, $item) use ($table_id, &$redirection_form_id, $filter, $compact_date, $external_url, $compact_name_event) { global $config; $tmp = (object) $item; @@ -518,7 +519,7 @@ if (is_ajax() === true) { $tmp->evento = ui_print_truncate_text( $tmp->evento, - 'description', + (empty($compact_name_event) === true) ? 'description' : GENERIC_SIZE_TEXT, false, true, false, diff --git a/pandora_console/views/tacticalView/view.php b/pandora_console/views/tacticalView/view.php index e09e5f16ae..a7fad1ee86 100644 --- a/pandora_console/views/tacticalView/view.php +++ b/pandora_console/views/tacticalView/view.php @@ -41,32 +41,34 @@ -
-
- - - - getLicenseUsageGraph(); ?> + +
+
+ + + + getLicenseUsageGraph(); ?> +
-
+
-
+
title; ?>
-
-
+
+
- getTagsGraph(); ?> + getMonitoringStatusGraph(); ?>
-
+
- getMonitoringStatusGraph(); ?> + getTagsGraph(); ?>
+
@@ -184,7 +187,7 @@ getTotalSources(); ?>
-
+
@@ -221,6 +224,7 @@
+
@@ -236,13 +240,13 @@
- getCurrentlyTriggered(); ?> + getCurrentlyTriggered(); ?>
- getActiveAlerts(); ?> + getActiveAlerts(); ?>
checkAclUserList() === true) : ?> @@ -261,13 +265,13 @@
title; ?>
-