wip chart histogram list modules #8222

This commit is contained in:
Daniel Barbero Martin 2021-12-14 13:21:34 +01:00
parent fa6690b55a
commit f705cc0fba
6 changed files with 326 additions and 211 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 933 B

View File

@ -1189,14 +1189,25 @@ if (check_login()) {
$data[8] = ' '; $data[8] = ' ';
if ($module['history_data'] == 1) { if ($module['history_data'] == 1) {
$tresholds = true;
if (empty((float) $module['min_warning']) === true
&& empty((float) $module['max_warning']) === true
&& empty($module['warning_inverse']) === true
&& empty((float) $module['min_critical']) === true
&& empty((float) $module['max_critical']) === true
&& empty($module['critical_inverse']) === true
) {
$tresholds = false;
}
$nombre_tipo_modulo = modules_get_moduletype_name($module['id_tipo_modulo']); $nombre_tipo_modulo = modules_get_moduletype_name($module['id_tipo_modulo']);
$handle = 'stat'.$nombre_tipo_modulo.'_'.$module['id_agente_modulo']; $handle = 'stat'.$nombre_tipo_modulo.'_'.$module['id_agente_modulo'];
$url = 'include/procesos.php?agente='.$module['id_agente_modulo']; $url = 'include/procesos.php?agente='.$module['id_agente_modulo'];
$win_handle = dechex(crc32($module['id_agente_modulo'].$module['nombre'])); $win_handle = dechex(crc32($module['id_agente_modulo'].$module['nombre']));
// Try to display the SNMP module realtime graph // Try to display the SNMP module realtime graph.
$rt_button = get_module_realtime_link_graph($module); $rt_button = get_module_realtime_link_graph($module);
if (!empty($rt_button)) { if (empty($rt_button) === false) {
$data[8] = $rt_button.'  '; $data[8] = $rt_button.'  ';
} }
@ -1207,6 +1218,19 @@ if (check_login()) {
$draw_events = 0; $draw_events = 0;
} }
if ($tresholds === true || $graph_type === 'boolean') {
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&".'period='.SECONDS_1DAY.'&id='.$module['id_agente_modulo'].'&refresh='.SECONDS_10MINUTES.'&'."histogram=1', 'day_".$win_handle."', 800, 480)";
$data[8] .= '<a href="javascript:'.$link.'">'.html_print_image(
'images/histograma.png',
true,
[
'border' => '0',
'alt' => '',
'class' => 'invert_filter',
]
).'</a> &nbsp;&nbsp;';
}
$link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&amp;".'period='.SECONDS_1DAY.'&amp;id='.$module['id_agente_modulo'].'&amp;refresh='.SECONDS_10MINUTES.'&amp;'."draw_events=$draw_events', 'day_".$win_handle."', 800, 480)"; $link = "winopeng_var('".'operation/agentes/stat_win.php?'."type=$graph_type&amp;".'period='.SECONDS_1DAY.'&amp;id='.$module['id_agente_modulo'].'&amp;refresh='.SECONDS_10MINUTES.'&amp;'."draw_events=$draw_events', 'day_".$win_handle."', 800, 480)";
if (!is_snapshot_data($module['datos'])) { if (!is_snapshot_data($module['datos'])) {
$data[8] .= '<a href="javascript:'.$link.'">'.html_print_image( $data[8] .= '<a href="javascript:'.$link.'">'.html_print_image(
@ -1349,9 +1373,30 @@ if (check_login()) {
metaconsole_connect($server); metaconsole_connect($server);
} }
$output .= grafico_modulo_sparse($params); if ($params['histogram'] === true) {
echo $output; $params['id_agent_module'] = $params['agent_module_id'];
$params['dinamic_proc'] = 1;
$output .= '<div class="stat_win_histogram">';
if ($params['compare'] === 'separated') {
$graph = \reporting_module_histogram_graph(
['datetime' => ($params['begin_date'] - $params['period'])],
$params
);
$output .= $graph['chart'];
}
$graph = \reporting_module_histogram_graph(
['datetime' => $params['begin_date']],
$params
);
$output .= $graph['chart'];
$output .= '</div>';
} else {
$output .= grafico_modulo_sparse($params);
}
echo $output;
if (is_metaconsole() === true && empty($server_id) === false) { if (is_metaconsole() === true && empty($server_id) === false) {
metaconsole_restore_db(); metaconsole_restore_db();
} }

View File

@ -14171,6 +14171,9 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
if ($modules_is_string === false) { if ($modules_is_string === false) {
if ($agentmodule_info['max_critical'] == 0) { if ($agentmodule_info['max_critical'] == 0) {
$max_value_critical = null; $max_value_critical = null;
if ((bool) $content['dinamic_proc'] === true) {
$max_value_critical = 0.01;
}
} else { } else {
$max_value_critical = $agentmodule_info['max_critical']; $max_value_critical = $agentmodule_info['max_critical'];
} }
@ -14378,6 +14381,7 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
$width_graph = 100; $width_graph = 100;
$height_graph = 80; $height_graph = 80;
if (empty($array_result) === false) {
$return['chart'] = flot_slicesbar_graph( $return['chart'] = flot_slicesbar_graph(
$array_result, $array_result,
$time_total, $time_total,
@ -14396,8 +14400,16 @@ function reporting_module_histogram_graph($report, $content, $pdf=0)
true, true,
$ttl, $ttl,
$content['sizeForTicks'], $content['sizeForTicks'],
true true,
$report['datetime']
); );
} else {
$return['chart'] = graph_nodata_image(
$width_graph,
$height_graph,
'area'
);
}
if ($metaconsole_on) { if ($metaconsole_on) {
// Restore db connection. // Restore db connection.

View File

@ -378,6 +378,8 @@ class GraphModuleHistogramWidget extends Widget
$size = parent::getSize(); $size = parent::getSize();
$output = '';
// Desactive scroll bars only this item. // Desactive scroll bars only this item.
$id_agent = $this->values['agentId']; $id_agent = $this->values['agentId'];
$id_module = $this->values['moduleId']; $id_module = $this->values['moduleId'];

View File

@ -8385,3 +8385,13 @@ div.stat-win-spinner img {
margin: 5px; margin: 5px;
font-size: 12px; font-size: 12px;
} }
.stat_win_histogram {
width: 95%;
margin: 0 auto;
margin-top: 18%;
}
#stat-win-module-graph .stat_win_histogram div.nodata_container {
width: 100%;
}

View File

@ -194,7 +194,28 @@ ui_print_message_dialog(
$time_compare_separated = get_parameter('time_compare_separated', 0); $time_compare_separated = get_parameter('time_compare_separated', 0);
$time_compare_overlapped = get_parameter('time_compare_overlapped', 0); $time_compare_overlapped = get_parameter('time_compare_overlapped', 0);
$unknown_graph = get_parameter_checkbox('unknown_graph', 1); $unknown_graph = get_parameter_checkbox('unknown_graph', 1);
$histogram = (bool) get_parameter('histogram', 0);
// FORM TABLE.
$table = html_get_predefined_table('transparent', 2);
$table->width = '100%';
$table->id = 'stat_win_form_div';
$table->style[0] = 'text-align:left;';
$table->style[1] = 'text-align:left;';
$table->style[2] = 'text-align:left;font-weight: bold;';
$table->style[3] = 'text-align:left;';
$table->class = 'table_modal_alternate';
$table->data = [];
$time_compare = false;
if ($time_compare_separated) {
$time_compare = 'separated';
} else if ($time_compare_overlapped) {
$time_compare = 'overlapped';
}
if ($histogram === false) {
$fullscale_sent = get_parameter('fullscale_sent', 0); $fullscale_sent = get_parameter('fullscale_sent', 0);
if (!$fullscale_sent) { if (!$fullscale_sent) {
if (isset($config['full_scale_option']) === false if (isset($config['full_scale_option']) === false
@ -219,14 +240,6 @@ ui_print_message_dialog(
($fullscale === 1) ? 0 : $config['type_mode_graph'] ($fullscale === 1) ? 0 : $config['type_mode_graph']
); );
$time_compare = false;
if ($time_compare_separated) {
$time_compare = 'separated';
} else if ($time_compare_overlapped) {
$time_compare = 'overlapped';
}
if ($zoom > 1) { if ($zoom > 1) {
$height = ($height * ($zoom / 2.1)); $height = ($height * ($zoom / 2.1));
$width = ($width * ($zoom / 1.4)); $width = ($width * ($zoom / 1.4));
@ -249,17 +262,6 @@ ui_print_message_dialog(
$id $id
); );
// FORM TABLE.
$table = html_get_predefined_table('transparent', 2);
$table->width = '100%';
$table->id = 'stat_win_form_div';
$table->style[0] = 'text-align:left;';
$table->style[1] = 'text-align:left;';
$table->style[2] = 'text-align:left;font-weight: bold;';
$table->style[3] = 'text-align:left;';
$table->class = 'table_modal_alternate';
$table->data = [];
$table->data[0][0] = __('Refresh time'); $table->data[0][0] = __('Refresh time');
$table->data[0][1] = html_print_extended_select_for_time( $table->data[0][1] = html_print_extended_select_for_time(
'refresh', 'refresh',
@ -413,6 +415,46 @@ ui_print_message_dialog(
true, true,
false false
); );
} else {
$table->data[0][0] = __('Begin date');
$table->data[0][1] = html_print_input_text(
'start_date',
$start_date,
'',
10,
20,
true
);
$table->data[0][2] = __('Begin time');
$table->data[0][3] = html_print_input_text(
'start_time',
$start_time,
'',
10,
10,
true
);
$table->data[1][0] = __('Time range');
$table->data[1][1] = html_print_extended_select_for_time(
'period',
$period,
'',
'',
0,
7,
true
);
$table->data[1][2] = __('Time compare (Separated)');
$table->data[1][3] = html_print_checkbox_switch(
'time_compare_separated',
1,
(bool) $time_compare_separated,
true
);
}
$form_table = html_print_table($table, true); $form_table = html_print_table($table, true);
$form_table .= '<div class="w100p right mrgn_top_15px right_align">'; $form_table .= '<div class="w100p right mrgn_top_15px right_align">';
@ -434,6 +476,8 @@ ui_print_message_dialog(
$menu_form .= html_print_input_hidden('server', $server_id, true); $menu_form .= html_print_input_hidden('server', $server_id, true);
} }
$menu_form .= html_print_input_hidden('histogram', $histogram, true);
if (isset($_GET['type']) === true) { if (isset($_GET['type']) === true) {
$type = get_parameter_get('type'); $type = get_parameter_get('type');
$menu_form .= html_print_input_hidden('type', $type, true); $menu_form .= html_print_input_hidden('type', $type, true);
@ -497,6 +541,8 @@ ui_print_message_dialog(
'zoom' => $zoom, 'zoom' => $zoom,
'height' => 300, 'height' => 300,
'type_mode_graph' => $type_mode_graph, 'type_mode_graph' => $type_mode_graph,
'histogram' => $histogram,
'begin_date' => strtotime($start_date.' '.$start_time),
]; ];
// Graph. // Graph.