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 '<div class="box-flat white_table_graph">'; + 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 '<p class="title-dialog">'.__('Module group').'</p>'; echo '<p class="info-dialog">'.$group.'</p>'; echo '</div>'; + + $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 '<div class="div-dialog">'; + echo '<p class="title-dialog">'.__('Data').'</p>'; + $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 '<p class="info-dialog">'.$data_module.' '.$data['unit'].' '.$img_graph.'</p>'; + } else { + $data_module = $data['datos']; + echo '<p class="info-dialog">'.$data['datos'].' '.$data['unit'].' '.$img_graph.'</p>'; + } + + echo '</div>'; + + echo '<div class="div-dialog">'; + echo '<p class="title-dialog">'.__('Date of last data').'</p>'; + echo '<p class="info-dialog">'.date('Y-m-d H:i:s', $data['utimestamp']).'</p>'; + echo '</div>'; + + $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 '<div class="div-dialog">'; + echo '<p class="title-dialog">'.__('Status').'</p>'; + echo '<div class="status_rounded_rectangles">'.$status.'</div>'; + echo '</div>'; break; case 1: @@ -381,6 +474,43 @@ if (is_ajax() === true) { echo '<p class="info-dialog">'.$data['comentarios'].'</p>'; echo '</div>'; + // 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 '<div class="div-dialog">'; + echo '<p class="title-dialog">'.__('Last contact').' / '.__('Remote').'</p>'; + echo '<p class="info-dialog">'.$lastAndRemoteContact.'</p>'; + echo '</div>'; + + + // 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 '<div class="div-dialog">'; + echo '<p class="title-dialog">'.__('Next contact').'</p>'; + echo '<p class="info-dialog">'.ui_progress( + $progress, + '80%', + '1.2', + '#ececec', + true, + $progressCaption, + [ + 'page' => 'operation/agentes/ver_agente', + 'interval' => $ajaxNextContactInterval, + 'data' => [ + 'id_agente' => $id, + 'refresh_contact' => 1, + ], + + ] + ).'</p>'; + echo '</div>'; + // Group. $secondary_groups = ''; $secondary = enterprise_hook('agents_get_secondary_groups', [$data['id_agente']]); @@ -394,6 +524,27 @@ if (is_ajax() === true) { echo '<p class="info-dialog">'.groups_get_name($data['id_grupo']).$secondary_groups.'</p>'; echo '</div>'; + echo '<div class="div-dialog">'; + echo graph_agent_status( + $id, + 150, + 150, + true, + false, + false, + true + ); + echo '</div>'; + echo '<div class="div-dialog" style="justify-content: center;">'; + echo reporting_tiny_stats( + $data, + true, + 'agent', + // Useless. + ':', + true + ); + echo '</div>'; // Events. $result_graph_event = enterprise_hook( @@ -419,6 +570,8 @@ if (is_ajax() === true) { break; } + echo '</div>'; + 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..94b8fef429 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: '<?php echo __('Info'); ?>', open: function() { $.ajax({ @@ -1325,13 +1359,23 @@ class Heatmap if (count($groups) > 1 && $this->group === 1 && $this->dashboard === false) { $x_back = 0; $y_back = 0; + $x_text_correction = 0.25; - if ($count_result <= 100) { + if ($count_result <= 10) { $fontSize = 'small-size'; $stroke = 'small-stroke'; - } else { + } else if ($count_result > 10 && $count_result <= 100) { + $fontSize = 'tiny-size'; + $stroke = 'tiny-stroke'; + } else if ($count_result > 100 && $count_result <= 1000) { + $fontSize = 'medium-size'; + $stroke = 'medium-stroke'; + } else if ($count_result > 1000 && $count_result <= 10000) { $fontSize = 'big-size'; $stroke = 'big-stroke'; + } else { + $fontSize = 'huge-size'; + $stroke = 'huge-stroke'; } echo '<polyline points="0,0 '.$Xaxis.',0" class="polyline '.$stroke.'" />'; @@ -1385,7 +1429,7 @@ class Heatmap echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />'; // Name. - echo '<text x="'.((($x_position - $x_back) / 2) + $x_back).'" y="'.($y_position + 1).'" + echo '<text x="'.((($x_position - $x_back) / 2) + $x_back - $x_text_correction).'" y="'.($y_position + 1 - 0.01).'" class="'.$fontSize.'">'.$name.'</text>'; $x_back = $x_position; @@ -1436,7 +1480,7 @@ class Heatmap echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />'; // Name. - echo '<text x="'.(($x_position) / 2).'" y="'.($y_position + 1).'" + echo '<text x="'.(($x_position) / 2 - $x_text_correction).'" y="'.($y_position + 1 - 0.01).'" class="'.$fontSize.'">'.$name.'</text>'; // Bottom-right of last line. @@ -1493,7 +1537,7 @@ class Heatmap echo '<polyline points="'.$points.'" class="polyline '.$stroke.'" />'; // Name. - echo '<text x="'.(($x_position) / 2).'" y="'.($y_position + 1).'" + echo '<text x="'.(($x_position) / 2 - $x_text_correction).'" y="'.($y_position + 1 - 0.02).'" class="'.$fontSize.'">'.$name.'</text>'; // Bottom-top of last line. 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..34df84e1c1 100644 --- a/pandora_console/include/styles/heatmap.css +++ b/pandora_console/include/styles/heatmap.css @@ -185,8 +185,6 @@ .hover:hover { filter: brightness(1.5); - stroke-width: 0.009; - stroke: black; } .group { @@ -255,13 +253,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 { @@ -271,17 +270,77 @@ div#heatmap-controls div.heatmap-refr > div { } .small-stroke { - stroke-width: 0.03; + stroke-width: 0.005; +} + +.tiny-stroke { + stroke-width: 0.01; +} + +.medium-stroke { + stroke-width: 0.02; } .big-stroke { - stroke-width: 0.05; + stroke-width: 0.03; +} + +.huge-stroke { + stroke-width: 0.04; } .small-size { - font-size: 0.2px; + font-size: 1%; +} + +.tiny-size { + font-size: 2%; +} + +.medium-size { + font-size: 4%; } .big-size { - font-size: 0.4px; + font-size: 6%; +} + +.huge-size { + font-size: 8%; +} + +.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.' <div class="agent_details_content"> <div class="agent_details_graph"> @@ -352,26 +343,6 @@ $table_agent = $agentStatusHeader.' </div>'; - /* - $table_agent = ' - <div class="agent_details_header"> - '.$table_agent_header.' - </div> - <div class="agent_details_content"> - <div class="agent_details_graph"> - '.$table_agent_graph.' - <div class="agent_details_bullets"> - '.$table_agent_count_modules.' - </div> - </div> - <div class="agent_details_info"> - '.$alive_animation.$table_agent_os.$table_agent_ip.$table_agent_version.$table_agent_description.$remote_cfg.' - </div> - </div>'; - - */ - - /* * END: TABLE AGENT BUILD. */