diff --git a/pandora_console/include/ajax/heatmap.ajax.php b/pandora_console/include/ajax/heatmap.ajax.php index 37806fb4a4..8ce0691a3d 100644 --- a/pandora_console/include/ajax/heatmap.ajax.php +++ b/pandora_console/include/ajax/heatmap.ajax.php @@ -137,6 +137,7 @@ if (is_ajax() === true) { switch ($type) { case 0: + case 3: default: $label = __('Group'); $input = html_print_input( @@ -234,10 +235,6 @@ if (is_ajax() === true) { '5' ); break; - - case 3: - // Empty. - break; } echo html_print_label_input_block( @@ -246,6 +243,7 @@ if (is_ajax() === true) { [ 'label_class' => 'font-title-font', 'div_class' => 'mrgn_top_10px', + 'div_id' => 'filter_type', ] ); } @@ -259,10 +257,19 @@ if (is_ajax() === true) { $nd->connect(); } + echo '
'; + switch ($type) { case 3: case 2: - $data = db_get_row('tagente_modulo', 'id_agente_modulo', $id); + $sql = sprintf( + 'SELECT * FROM tagente_modulo ag + INNER JOIN tagente_estado ae ON ag.id_agente_modulo = ae.id_agente_modulo + WHERE ag.id_agente_modulo = %d', + $id + ); + + $data = db_get_row_sql($sql); // Nombre. $link = sprintf( @@ -298,6 +305,92 @@ if (is_ajax() === true) { echo '

'.__('Module group').'

'; echo '

'.$group.'

'; echo '
'; + + $graph_type = return_graphtype($data['module_type']); + + $url = ui_get_full_url('operation/agentes/stat_win.php', false, false, false); + $handle = dechex(crc32($data['id_agente_modulo'].$data['module_name'])); + $win_handle = 'day_'.$handle; + + $graph_params = [ + 'type' => $graph_type, + 'period' => SECONDS_1DAY, + 'id' => $data['id_agente_modulo'], + 'refresh' => SECONDS_10MINUTES, + ]; + + + $graph_params_str = http_build_query($graph_params); + + $link = 'winopeng_var(\''.$url.'?'.$graph_params_str.'\',\''.$win_handle.'\', 800, 480)'; + $img_graph = html_print_anchor( + [ + 'href' => 'javascript:'.$link, + 'content' => html_print_image('images/module-graph.svg', true, ['border' => '0', 'alt' => '', 'class' => 'invert_filter main_menu_icon']), + ], + true + ); + + + echo '
'; + echo '

'.__('Data').'

'; + $data_module = ''; + if (is_numeric($data['datos'])) { + $data_module = remove_right_zeros( + number_format( + $data['datos'], + $config['graph_precision'], + $config['decimal_separator'], + $config['thousand_separator'] + ) + ); + echo '

'.$data_module.' '.$data['unit'].'   '.$img_graph.'

'; + } else { + $data_module = $data['datos']; + echo '

'.$data['datos'].' '.$data['unit'].'   '.$img_graph.'

'; + } + + echo '
'; + + echo '
'; + echo '

'.__('Date of last data').'

'; + echo '

'.date('Y-m-d H:i:s', $data['utimestamp']).'

'; + echo '
'; + + $status = modules_get_agentmodule_status($id); + switch ($status) { + case AGENT_MODULE_STATUS_NORMAL: + $status = ui_print_status_image('module_ok.png', $data_module, true); + break; + + case AGENT_MODULE_STATUS_CRITICAL_BAD: + $status = ui_print_status_image('module_critical.png', $data_module, false); + break; + + case AGENT_MODULE_STATUS_WARNING: + $status = ui_print_status_image('module_warning.png', $data_module, false); + break; + + case AGENT_MODULE_STATUS_NORMAL_ALERT: + case AGENT_MODULE_STATUS_WARNING_ALERT: + case AGENT_MODULE_STATUS_CRITICAL_ALERT: + $status = ui_print_status_image('module_alertsfired.png', $data_module, false); + break; + + case 4: + $status = ui_print_status_image('module_no_data.png', $data_module, false); + break; + + default: + case AGENT_MODULE_STATUS_UNKNOWN: + $status = ui_print_status_image('module_unknown.png', $data_module, false); + break; + } + + echo '
'; + echo '

'.__('Status').'

'; + echo '
'.$status.'
'; + echo '
'; break; case 1: @@ -381,6 +474,43 @@ if (is_ajax() === true) { echo '

'.$data['comentarios'].'

'; echo ''; + // Last contact. + $lastContactDate = ui_print_timestamp($data['ultimo_contacto'], true); + $remoteContactDate = ($data['ultimo_contacto_remoto'] === '01-01-1970 00:00:00') ? __('Never') : date_w_fixed_tz($data['ultimo_contacto_remoto']); + $lastAndRemoteContact = sprintf('%s / %s', $lastContactDate, $remoteContactDate); + + echo '
'; + echo '

'.__('Last contact').' / '.__('Remote').'

'; + echo '

'.$lastAndRemoteContact.'

'; + echo '
'; + + + // Next contact progress. + $progress = agents_get_next_contact($id); + $tempTimeToShow = ($data['intervalo'] - (strtotime('now') - strtotime($data['ultimo_contacto']))); + $progressCaption = ($tempTimeToShow >= 0) ? sprintf('%d s', $tempTimeToShow) : __('Out of bounds'); + $ajaxNextContactInterval = (empty($data['intervalo']) === true) ? 0 : (100 / $data['intervalo']); + echo '
'; + echo '

'.__('Next contact').'

'; + echo '

'.ui_progress( + $progress, + '80%', + '1.2', + '#ececec', + true, + $progressCaption, + [ + 'page' => 'operation/agentes/ver_agente', + 'interval' => $ajaxNextContactInterval, + 'data' => [ + 'id_agente' => $id, + 'refresh_contact' => 1, + ], + + ] + ).'

'; + echo '
'; + // Group. $secondary_groups = ''; $secondary = enterprise_hook('agents_get_secondary_groups', [$data['id_agente']]); @@ -394,6 +524,27 @@ if (is_ajax() === true) { echo '

'.groups_get_name($data['id_grupo']).$secondary_groups.'

'; echo ''; + echo '
'; + echo graph_agent_status( + $id, + 150, + 150, + true, + false, + false, + true + ); + echo '
'; + echo '
'; + echo reporting_tiny_stats( + $data, + true, + 'agent', + // Useless. + ':', + true + ); + echo '
'; // Events. $result_graph_event = enterprise_hook( @@ -419,6 +570,8 @@ if (is_ajax() === true) { break; } + echo ''; + if (empty($id_server) === false) { $nd->disconnect(); } diff --git a/pandora_console/include/class/Heatmap.class.php b/pandora_console/include/class/Heatmap.class.php index de3ef90ba3..e7b6ab6f2b 100644 --- a/pandora_console/include/class/Heatmap.class.php +++ b/pandora_console/include/class/Heatmap.class.php @@ -282,7 +282,6 @@ class Heatmap while (cont <= limit) { if (typeof lista[cont] !== 'undefined') { const rect = document.getElementsByName(`${lista[cont]['id']}`); - console.log(rect[0]); $(`#${rect[0].id}`).removeClass(); $(`#${rect[0].id}`).addClass(`${lista[cont]['status']} hover`); } @@ -938,10 +937,27 @@ class Heatmap if (users_is_admin() === false) { $user_groups = array_keys(users_get_groups($config['user'], 'AR', false)); if (empty($user_groups) === false) { + if (empty($this->filter) === false && empty(current($this->filter)) === false) { + $user_groups = array_intersect($this->filter, $user_groups); + $id_user_groups = sprintf( + 'INNER JOIN tagente a ON a.id_agente = ae.id_agente + AND a.id_grupo IN (%s)', + implode(',', $user_groups) + ); + } else { + $id_user_groups = sprintf( + 'INNER JOIN tagente a ON a.id_agente = ae.id_agente + AND a.id_grupo IN (%s)', + implode(',', $user_groups) + ); + } + } + } else { + if (empty($this->filter) === false && empty(current($this->filter)) === false) { $id_user_groups = sprintf( 'INNER JOIN tagente a ON a.id_agente = ae.id_agente AND a.id_grupo IN (%s)', - implode(',', $user_groups) + implode(',', $this->filter) ); } } @@ -1292,13 +1308,31 @@ class Heatmap const id = name.split('|')[0]; const server = name.split('|')[1]; + let height = 400; + let width = 530; + switch (type) { + case 0: + height = 670; + width = 460; + break; + + case 2: + case 3: + height = 450; + width = 460; + break; + + default: + break; + } + $("#info_dialog").dialog({ resizable: true, draggable: true, modal: true, closeOnEscape: true, - height: 400, - width: 530, + height: height, + width: width, title: '', open: function() { $.ajax({ diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index f46c64082f..a22c94b2ab 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -1571,16 +1571,12 @@ function type_change() { var type = document.getElementById("type").value; switch (type) { - case "3": - $("#li_tags").hide(); - $("#li_groups").hide(); - $("#li_module_groups").hide(); - break; case "2": $("#li_tags").hide(); $("#li_groups").hide(); $("#li_module_groups").show(); break; + case "1": $("#li_tags").show(); $("#li_groups").hide(); @@ -1588,6 +1584,7 @@ function type_change() { break; default: + case "3": case "0": $("#li_tags").hide(); $("#li_groups").show(); diff --git a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php index 2f9d9533cd..bca4d704ee 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/heatmap.php +++ b/pandora_console/include/lib/Dashboard/Widgets/heatmap.php @@ -264,7 +264,7 @@ class HeatmapWidget extends Widget // Filters. $inputs[] = [ 'label' => __('Groups'), - 'style' => ($values['type'] === '0') ? '' : 'display:none', + 'style' => ($values['type'] === '0' || $values['type'] === '3') ? '' : 'display:none', 'id' => 'li_groups', 'arguments' => [ 'type' => 'select_groups', @@ -363,6 +363,7 @@ class HeatmapWidget extends Widget break; case 0: + case 3: $values['groups'] = \get_parameter('groups', 0); break; diff --git a/pandora_console/include/styles/heatmap.css b/pandora_console/include/styles/heatmap.css index 12db5cc399..69a2832fe0 100644 --- a/pandora_console/include/styles/heatmap.css +++ b/pandora_console/include/styles/heatmap.css @@ -255,13 +255,14 @@ div#heatmap-controls div.heatmap-refr > div { .title-dialog { width: 40%; - font-weight: bold; + font-weight: bold !important; padding-left: 20px; } .info-dialog { width: 60%; - font-weight: bold; + display: flex; + align-items: center; } .polyline { @@ -285,3 +286,39 @@ div#heatmap-controls div.heatmap-refr > div { .big-size { font-size: 0.4px; } + +.progress_main { + height: 2.5em; + border: 2px solid #82b92e; + position: relative; + width: 100%; + display: inline-block; + display: flex; + border-radius: 4px; + line-height: 9pt; + font-size: 9pt; +} + +.progress_main_noborder { + height: 2.5em; + position: relative; + width: 100%; + display: inline-block; + display: flex; +} + +.progress_main:before { + content: attr(data-label); + position: absolute; + text-align: center; + left: 0; + right: 0; + margin-top: 0.2em; +} + +.progress { + width: 0%; + background: #82b92e; + height: 100%; + float: left; +} diff --git a/pandora_console/operation/agentes/estado_generalagente.php b/pandora_console/operation/agentes/estado_generalagente.php index c79a868f5d..a013ccf8cf 100755 --- a/pandora_console/operation/agentes/estado_generalagente.php +++ b/pandora_console/operation/agentes/estado_generalagente.php @@ -331,16 +331,7 @@ if ((bool) $has_remote_conf) { } } -// $table_agent_count_modules .= ui_print_help_tip(__('Agent statuses are re-calculated by the server, they are not shown in real time.'), true); -/* - $table_agent = html_print_div( - [ - 'class' => 'agent_details_header', - 'content' => $table_agent_header, - ], - true - ); -*/ + $table_agent = $agentStatusHeader.'
@@ -352,26 +343,6 @@ $table_agent = $agentStatusHeader.'
'; - /* - $table_agent = ' -
- '.$table_agent_header.' -
-
-
- '.$table_agent_graph.' -
- '.$table_agent_count_modules.' -
-
-
- '.$alive_animation.$table_agent_os.$table_agent_ip.$table_agent_version.$table_agent_description.$remote_cfg.' -
-
'; - - */ - - /* * END: TABLE AGENT BUILD. */