fixed errors in graphs

This commit is contained in:
daniel 2017-12-13 17:17:45 +01:00
parent fedb6003dd
commit 4a1a0ae8b7
13 changed files with 708 additions and 162 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -2580,7 +2580,7 @@ function get_percentile($percentile, $array) {
$index = ($percentile / 100) * count($array);
if (floor($index) == $index) {
$result = ($array[$index-1] + $array[$index]) / 2;
$result = ($array[$index-1] + $array[$index]) / 2;
}
else {
$result = $array[floor($index)];

View File

@ -610,9 +610,18 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
}
$module_type = $module['id_tipo_modulo'];
$module_type_str = modules_get_type_name ($module_type);
if (strstr ($module_type_str, 'string') !== false) {
$table = "tagente_datos_string";
}
$flag_async = false;
if(strstr ($module_type_str, 'async_data') !== false) {
$flag_async = true;
}
if(strstr ($module_type_str, 'async_proc') !== false) {
$flag_async = true;
}
$result = modules_get_first_date($id_agente_modulo,$tstart);
$first_utimestamp = $result["first_utimestamp"];
@ -663,18 +672,23 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
// Retrieve going unknown events in range
$unknown_events = db_get_module_ranges_unknown($id_agente_modulo, $tstart, $tend, $search_historydb);
$previous_unknown_events = db_get_module_ranges_unknown(
$id_agente_modulo,
$tstart - (SECONDS_1DAY + 2*$module_interval),
$tstart,
// Get the last event after inverval to know if graph start on unknown
$previous_unknown_events = db_get_row_filter (
'tevento',
array ('id_agentmodule' => $id_agente_modulo,
"utimestamp <= $tstart",
'order' => 'utimestamp DESC'
),
false,
'AND',
$search_historydb
);
//don't show graph if graph is inside unknown
if( $previous_unknown_events &&
!isset($previous_unknown_events[count($previous_unknown_events) -1]['time_to']) &&
//show graph if graph is inside unknown
if( $previous_unknown_events && $previous_unknown_events['event_type'] == 'going_unknown' &&
$unknown_events === false && $raw_data === false){
return false;
$last_inserted_value = $first_data["datos"];
$unknown_events[0]['time_from'] = $tstart+0.1;
}
//if time to is missing in last event force time to outside range time
@ -683,11 +697,14 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
}
//if time to is missing in first event force time to outside range time
if ($first_data["datos"] === false) {
if ($first_data["datos"] === false && !$flag_async) {
$last_inserted_value = false;
}elseif( $unknown_events && !isset($unknown_events[0]['time_from']) ||
$first_utimestamp < $tstart - (SECONDS_1DAY + 2*$module_interval) ){
$last_inserted_value = null;
}elseif( ($unknown_events && !isset($unknown_events[0]['time_from']) &&
$previous_unknown_events && $previous_unknown_events['event_type'] == 'going_unknown' && !$flag_async) ||
($first_utimestamp < $tstart - (SECONDS_1DAY + 2*$module_interval) && !$flag_async) ){
//$last_inserted_value = null;
$last_inserted_value = $first_data["datos"];
$unknown_events[0]['time_from'] = $tstart+0.1;
}
else{
$last_inserted_value = $first_data["datos"];
@ -703,26 +720,46 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
$last_timestamp = $first_data["utimestamp"];
$last_value = $first_data["datos"];
//reverse array data optimization
$raw_data = array_reverse($raw_data);
// Build template
$pool_id = 0;
$now = time();
$current_unknown = array_shift($unknown_events);
$current_raw_data = array_shift($raw_data);
if($unknown_events){
$current_unknown = array_shift($unknown_events);
}
else{
$current_unknown = null;
}
if($raw_data){
$current_raw_data = array_pop($raw_data);
}
else{
$current_raw_data = null;
}
while ( $current_timestamp < $tend ) {
$return[$pool_id]["data"] = array();
$tmp_data = array();
$current_timestamp_end = $current_timestamp + $slice_size;
if ( ( $current_timestamp > $now) ||
( ($current_timestamp_end - $last_timestamp) >
(SECONDS_1DAY + 2*$module_interval) ) ) {
$tmp_data["utimestamp"] = $last_timestamp + SECONDS_1DAY + 2*$module_interval;
if (( $current_timestamp > $now) ||
( ($current_timestamp_end - $last_timestamp) >
(SECONDS_1DAY + 2 * $module_interval) ) ) {
$tmp_data["utimestamp"] = $last_timestamp + SECONDS_1DAY + 2 * $module_interval;
//check not init
$tmp_data["datos"] = $last_value === false ? false : null;
//async not unknown
if($flag_async && $tmp_data["datos"] === null){
$tmp_data["datos"] = $last_inserted_value;
}
// debug purpose
//$tmp_data["obs"] = "unknown extra";
array_push($return[$pool_id]["data"], $tmp_data);
@ -751,49 +788,60 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
$last_value = $current_raw_data["datos"];
$last_timestamp = $current_raw_data["utimestamp"];
$current_raw_data = array_shift($raw_data);
if($raw_data){
$current_raw_data = array_pop($raw_data);
}
else{
$current_raw_data = null;
}
}
//unknown
$data_slices = $return[$pool_id]["data"];
while ( ($current_unknown != null) &&
( ( ($current_unknown['time_from'] != null) &&
($current_timestamp_end >= $current_unknown['time_from']) ) ||
($current_timestamp_end >= $current_unknown['time_to']) ) ) {
if( ( $current_timestamp <= $current_unknown['time_from']) &&
( $current_timestamp_end >= $current_unknown['time_from'] ) ){
// Add unknown state detected
$tmp_data["utimestamp"] = $current_unknown["time_from"];
$tmp_data["datos"] = null;
// debug purpose
//$tmp_data["obs"] = "event data unknown from";
array_push($return[$pool_id]["data"], $tmp_data);
$current_unknown["time_from"] = null;
}
if( ($current_timestamp < $current_unknown['time_to']) &&
($current_timestamp_end >= $current_unknown['time_to'] ) ){
$tmp_data["utimestamp"] = $current_unknown["time_to"];
$i = count($data_slices) - 1;
while ($i >= 0) {
if($data_slices[$i]['utimestamp'] <= $current_unknown["time_to"]){
$tmp_data["datos"] =
$data_slices[$i]['datos'] == null
? $last_value
: $data_slices[$i]['datos'];
break;
}
$i--;
if(!$flag_async){
while ( ($current_unknown != null) &&
( ( ($current_unknown['time_from'] != null) &&
($current_timestamp_end >= $current_unknown['time_from']) ) ||
($current_timestamp_end >= $current_unknown['time_to']) ) ) {
if( ( $current_timestamp <= $current_unknown['time_from']) &&
( $current_timestamp_end >= $current_unknown['time_from'] ) ){
// Add unknown state detected
$tmp_data["utimestamp"] = $current_unknown["time_from"];
$tmp_data["datos"] = null;
// debug purpose
//$tmp_data["obs"] = "event data unknown from";
array_push($return[$pool_id]["data"], $tmp_data);
$current_unknown["time_from"] = null;
}
if( ($current_timestamp <= $current_unknown['time_to']) &&
($current_timestamp_end >= $current_unknown['time_to'] ) ){
$tmp_data["utimestamp"] = $current_unknown["time_to"];
$i = count($data_slices) - 1;
while ($i >= 0) {
if($data_slices[$i]['utimestamp'] <= $current_unknown["time_to"]){
$tmp_data["datos"] =
$data_slices[$i]['datos'] == null
? $last_value
: $data_slices[$i]['datos'];
break;
}
$i--;
}
// debug purpose
//$tmp_data["obs"] = "event data unknown to";
array_push($return[$pool_id]["data"], $tmp_data);
if($unknown_events){
$current_unknown = array_shift($unknown_events);
}
else{
$current_unknown = null;
}
}
// debug purpose
//$tmp_data["obs"] = "event data unknown to";
array_push($return[$pool_id]["data"], $tmp_data);
$current_unknown = array_shift($unknown_events);
}
}
//sort current slice
usort(
$return[$pool_id]['data'],
@ -810,6 +858,15 @@ function db_uncompress_module_data($id_agente_modulo, $tstart = false, $tend = f
$pool_id++;
$current_timestamp = $current_timestamp_end;
}
//slice to the end.
if($pool_id == 1){
$end_array = array();
$end_array['data'][0]['utimestamp'] = $tend;
$end_array['data'][0]['datos'] = $last_inserted_value;
//$end_array['data'][0]['obs'] = 'virtual data END';
array_push($return, $end_array);
}
return $return;
}

View File

@ -247,27 +247,23 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
// Event iterator
$event_i = 0;
// Is unknown flag
$is_unknown = $start_unknown;
// Calculate chart data
$last_known = $previous_data;
$first_events_unknown = $start_unknown;
for ($i = 0; $i <= $resolution; $i++) {
$timestamp = $datelimit + ($interval * $i);
if ($fullscale && ($resolution > ($config['graph_res'] * 50))) {
$timestamp = $data[$i]['utimestamp'];
}
$total = 0;
$count = 0;
// Read data that falls in the current interval
$interval_min = false;
$interval_max = false;
while (isset ($data[$data_i]) && $data[$data_i]['utimestamp'] >= $timestamp && $data[$data_i]['utimestamp'] < ($timestamp + $interval)) {
while (isset ($data[$data_i]) && $data[$data_i]['utimestamp'] >= $timestamp
&& $data[$data_i]['utimestamp'] < ($timestamp + $interval)) {
if ($interval_min === false) {
$interval_min = $data[$data_i]['datos'];
}
@ -308,11 +304,17 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
$alert_value = 0;
$unknown_value = 0;
// Is the first point of a unknown interval
$check_unknown = false;
$first_unknown = false;
if($first_events_unknown){
$is_unknown = true;
}
$event_ids = array();
$alert_ids = array();
while (isset ($events[$event_i]) && $events[$event_i]['utimestamp'] >= $timestamp && $events[$event_i]['utimestamp'] <= ($timestamp + $interval)) {
while (isset ($events[$event_i]) && $events[$event_i]['utimestamp'] >= $timestamp
&& $events[$event_i]['utimestamp'] <= ($timestamp + $interval)) {
if ($show_events == 1) {
$event_value++;
$event_ids[] = $events[$event_i]['id_evento'];
@ -327,8 +329,11 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
$first_unknown = true;
}
$is_unknown = true;
$check_unknown = true;
}
else if (substr ($events[$event_i]['event_type'], 0, 5) == 'going') {
$first_events_unknown = false;
$first_unknown = false;
$is_unknown = false;
}
}
@ -489,9 +494,14 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
if (!isset($chart[$timestamp]['unknown'.$series_suffix])) {
$chart[$timestamp]['unknown'.$series_suffix] = 0;
}
$chart[$timestamp]['unknown'.$series_suffix] = $unknown_value;
$series_type['unknown'.$series_suffix] = 'area';
if($unknown_value == 0 && $check_unknown == true){
$chart[$timestamp]['unknown'.$series_suffix] = 1;
$check_unknown = false;
}
$series_type['unknown'.$series_suffix] = 'unknown';
}
if (!empty($event_ids)) {
@ -502,6 +512,14 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
}
}
//min paint graph 2 elements
if(count($chart) == 1){
$timestamp_short = date($time_format, $date_limit);
foreach($chart as $key => $value){
$chart[$timestamp_short] = $value;
}
}
if (!is_null($percentil) && $percentil) {
$avg = array_map(function($item) { return $item['sum'];}, $chart);
@ -546,8 +564,13 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$start_unknown = false;
// Set variables
if ($date == 0) $date = get_system_time();
if ($date == 0) {
$date = get_system_time();
}
$datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit);
if($force_interval){
@ -562,6 +585,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
}
else{
$interval = (int) ($period / $resolution);
}
$agent_name = modules_get_agentmodule_agent_name ($agent_module_id);
@ -617,7 +641,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
fullscale_data( $chart, $chart_data_extra, $long_index, $series_type,
$agent_module_id, $datelimit, $date, $events,
$show_events, $show_unknown, $show_alerts,
$series_suffix, $percentil, $flash_chart);
$series_suffix, $percentil, $flash_chart, false);
if (count($chart) > $resolution) {
$resolution = count($chart); //Number of points of the graph
$interval = (int) ($period / $resolution);
@ -629,45 +653,8 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
"utimestamp > $datelimit",
"utimestamp < $date",
'order' => 'utimestamp ASC'),
array ('datos', 'utimestamp'), 'AND', false);
array ('datos', 'utimestamp'), 'AND', $search_in_history_db);
if ($search_in_history_db) {
$cache = false;
$history = false;
$sql = "SELECT datos, utimestamp FROM tagente_datos WHERE id_agente_modulo = " . (int)$agent_module_id .
" AND utimestamp > " . $datelimit . " AND utimestamp < " . $date .
" ORDER BY utimestamp ASC";
// Connect to the history DB
if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) {
$config['history_db_connection'] = db_connect($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], io_output_password($config['history_db_pass']), $config['history_db_port'], false);
}
if ($config['history_db_connection'] !== false) {
$history = mysql_db_process_sql ($sql, 'affected_rows', $config['history_db_connection'], false);
}
if ($history === false) {
$history = array ();
}
$new_data = array();
$last_timestamp = 0;
foreach($history as $h) {
$new_data[] = $h;
$last_timestamp = $h['utimestamp'];
}
foreach($data as $d) {
if ($d['utimestamp'] > $last_timestamp) {
$new_data[] = $d;
$last_timestamp = $d['utimestamp'];
}
}
$data = $new_data;
}
if ($data === false) {
$data = array ();
}
@ -755,6 +742,18 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
// Calculate chart data
if($fullscale){
$avg_only = 1;
//Percentil
if (!is_null($percentil) && $percentil) {
$avg = array_map(function($item) { return $item['sum'];}, $chart);
$percentil_result = get_percentile($percentil, $avg);
//Fill the data of chart
array_walk($chart, function(&$item) use ($percentil_result, $series_suffix) {
$item['percentil' . $series_suffix] = $percentil_result; });
$series_type['percentil' . $series_suffix] = 'line';
}
}
else{
grafico_modulo_sparse_data_chart ($chart, $chart_data_extra, $long_index,
@ -765,7 +764,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$percentil, $fullscale, $force_interval, $time_interval,
$max_only, $min_only);
}
// Return chart data and don't draw
if ($return_data == 1) {
return $chart;
@ -782,8 +781,11 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$event_max = 5;
}
}
foreach ($chart as $timestamp => $chart_data) {
if($chart_data['max'] > $event_max){
$event_max = $chart_data['max'];
}
if ($show_events && $chart_data['event' . $series_suffix] > 0) {
$chart[$timestamp]['event' . $series_suffix] = $event_max * 1.2;
}
@ -1316,6 +1318,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
if ($data === false) {
$data = array ();
}
// Uncompressed module data
if ($uncompressed_module) {
@ -1346,7 +1349,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$min_necessary = 2;
}
// Set initial conditions
$graph_values[$i] = array();
@ -1431,7 +1434,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$min = null;
$avg = 0;
$countAvg = 0;
// Calculate chart data
$last_known = $previous_data;
for ($l = 0; $l <= $resolution; $l++) {
@ -1463,7 +1466,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$count++;
$j++;
}
// Average
if ($count > 0) {
$total /= $count;
@ -1511,7 +1514,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$min = $temp_graph_values[$timestamp_short];
}
$avg += $temp_graph_values[$timestamp_short];
// Added to support projection graphs
if ($projection != false and $i != 0) {
$projection_data = array();
@ -1522,7 +1525,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$graph_values[$i] = $temp_graph_values;
}
}
//Add the max, min and avg in the legend
$avg = round($avg / $countAvg, 1);
@ -1602,8 +1605,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$temp = array();
if ($flash_charts === false && $stacked == CUSTOM_GRAPH_GAUGE)
$stacked = CUSTOM_GRAPH_BULLET_CHART;
$stacked = CUSTOM_GRAPH_BULLET_CHART;
switch ($stacked) {
case CUSTOM_GRAPH_BULLET_CHART_THRESHOLD:
case CUSTOM_GRAPH_BULLET_CHART:
@ -1721,7 +1723,6 @@ function graphic_combined_module ($module_list, $weight_list, $period,
else
$module = $module_item;
$module_data = modules_get_agentmodule($module);
$query_last_value = sprintf('
SELECT datos
@ -1904,6 +1905,16 @@ function graphic_combined_module ($module_list, $weight_list, $period,
}
}
}
//check min array two elements
if(count($temp) == 1){
$timestamp_short = graph_get_formatted_date($date, $time_format, $time_format_2);
foreach($temp as $key => $value){
foreach($value as $k => $v){
$temp[$timestamp_short][$k] = $v;
}
}
}
break;
}
}
@ -1913,7 +1924,13 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$flash_charts = false;
}
$temp = fullscale_data_combined($module_list, $period, $date, $flash_charts);
$temp = fullscale_data_combined($module_list, $period, $date, $flash_charts, $percentil);
if (!is_null($percentil) && $percentil) {
if(isset($temp['percentil'])){
$percentil_result = array_pop($temp);
}
}
$resolution = count($temp); //Number of points of the graph
$interval = (int) ($period / $resolution);
@ -1942,10 +1959,20 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$module_name_list[$key] = $alias . " / " . $module_name;
}
}
}
$graph_values = $temp;
if (!is_null($percentil) && $percentil) {
foreach ($module_list as $key => $value) {
$agent_name = io_safe_output( modules_get_agentmodule_agent_name ($value) );
$alias = db_get_value ("alias","tagente","nombre",$agent_name);
$module_name = io_safe_output( modules_get_agentmodule_name ($value) );
$module_name_list['percentil'.$key] = __('Percentile %dº', $config['percentil']) . __(' of module ') . $agent_name .' / ' . $module_name . ' (' . $percentil_result[$key][0] . ' ' . $unit . ') ';
$series_type[$key] = 'line';
}
}
}
$graph_values = $temp;
if($config["fixed_graph"] == false){
$water_mark = array(
'file' => $config['homedir'] . "/images/logo_vertical_water.png",
@ -2193,8 +2220,8 @@ function graphic_combined_module ($module_list, $weight_list, $period,
}
}
function fullscale_data_combined($module_list, $period, $date, $flash_charts){
function fullscale_data_combined($module_list, $period, $date, $flash_charts, $percentil){
global $config;
// Set variables
if ($date == 0){
$date = get_system_time();
@ -2203,6 +2230,10 @@ function fullscale_data_combined($module_list, $period, $date, $flash_charts){
$datelimit = $date - $period;
foreach ($module_list as $key_module => $value_module) {
if (!is_null($percentil) && $percentil) {
$array_percentil = array();
}
$data_uncompress = db_uncompress_module_data($value_module, $datelimit, $date);
foreach ($data_uncompress as $key_data => $value_data) {
foreach ($value_data['data'] as $k => $v) {
@ -2212,14 +2243,24 @@ function fullscale_data_combined($module_list, $period, $date, $flash_charts){
else{
$real_date = $v['utimestamp'];
}
if (!is_null($percentil) && $percentil) {
$array_percentil[] = $v['datos'];
}
$data_all[$real_date][$key_module] = $v['datos'];
}
}
if (!is_null($percentil) && $percentil) {
$percentil_value = get_percentile($config['percentil'], $array_percentil);
$percentil_result[$key_module] = array_fill (0, count($data_all), $percentil_value);
}
}
$data_prev = array();
ksort($data_all);
//ksort($data_all);
foreach ($data_all as $key => $value) {
foreach ($module_list as $key_module => $value_module) {
if(!isset($value[$key_module])){
@ -2231,6 +2272,10 @@ function fullscale_data_combined($module_list, $period, $date, $flash_charts){
}
}
if (!is_null($percentil) && $percentil) {
$data_all['percentil'] = $percentil_result;
}
return $data_all;
}
@ -3953,7 +3998,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
$datelimit = $date - $period;
$search_in_history_db = db_search_in_history_db($datelimit);
$resolution = $config['graph_res'] * 50; //Number of points of the graph
$interval = (int) ($period / $resolution);
$interval = (float) ($period / $resolution);
$agent_name = modules_get_agentmodule_agent_name ($agent_module_id);
$agent_id = agents_get_agent_id ($agent_name);
$module_name = modules_get_agentmodule_name ($agent_module_id);
@ -4003,7 +4048,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
fullscale_data( $chart, $chart_data_extra, $long_index, $series_type,
$agent_module_id, $datelimit, $date, $events,
$show_events, $show_unknown, $show_alerts,
$series_suffix, $percentil, $flash_chart);
$series_suffix, $percentil, $flash_chart,true);
if (count($chart) > $resolution) {
$resolution = count($chart); //Number of points of the graph
$interval = (int) ($period / $resolution);
@ -4027,8 +4072,6 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
// Uncompressed module data
if ($uncompressed_module) {
$min_necessary = 1;
// Compressed module data
}
else {
// Get previous data
@ -4062,8 +4105,6 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
graphic_error ();
}
// Data iterator
$j = 0;
@ -4080,17 +4121,14 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
}
$max_value = 0;
// Calculate chart data
$last_known = $previous_data;
$first_events_unknown = $start_unknown;
for ($i = 0; $i <= $resolution; $i++) {
$timestamp = $datelimit + ($interval * $i);
/*
if ($fullscale && ($resolution > ($config['graph_res'] * 50))) {
$timestamp = $data[$i]['utimestamp'];
}
*/
$zero = 0;
$total = 0;
$count = 0;
@ -4124,10 +4162,13 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
$event_value = 0;
$alert_value = 0;
$unknown_value = 0;
// Is the first point of a unknown interval
$first_unknown = false;
$check_unknown = false;
$first_unknown = false;
if($first_events_unknown){
$is_unknown = true;
}
$event_ids = array();
$alert_ids = array();
while (isset ($events[$k]) &&
@ -4146,15 +4187,13 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
if ($is_unknown == false) {
$first_unknown = true;
}
else{
$first_unknown = false;
}
$check_unknown = true;
$is_unknown = true;
$check_unknown = true;
}
else if (substr ($events[$k]['event_type'], 0, 5) == 'going') {
$is_unknown = false;
$first_events_unknown = false;
$first_unknown = false;
$is_unknown = false;
}
}
$k++;
@ -4195,12 +4234,12 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
if ($total > $max_value) {
$max_value = $total;
}
// Data
if ($show_events) {
if (!isset($chart[$timestamp]['event'.$series_suffix])) {
$chart[$timestamp]['event'.$series_suffix] = 0;
}
$chart[$timestamp]['event'.$series_suffix] += $event_value;
$series_type['event'.$series_suffix] = 'points';
}
@ -4232,29 +4271,28 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
}
}
$series_type['sum' . $series_suffix] = 'boolean';
if ($show_unknown) {
if (!isset($chart[$timestamp]['unknown'.$series_suffix])) {
$chart[$timestamp]['unknown'.$series_suffix] = 0;
}
$chart[$timestamp]['unknown'.$series_suffix] = $unknown_value;
if($unknown_value == 0 && $check_unknown == true){
$chart[$timestamp]['unknown'.$series_suffix] = 1;
$check_unknown = false;
}
$series_type['unknown'.$series_suffix] = 'area';
$series_type['unknown'.$series_suffix] = 'unknown';
}
$series_type['sum' . $series_suffix] = 'boolean';
if (!empty($event_ids)) {
$chart_extra_data[count($chart)-1]['events'] = implode(',',$event_ids);
}
if (!empty($alert_ids)) {
$chart_extra_data[count($chart)-1]['alerts'] = implode(',',$alert_ids);
}
}
}
@ -4268,6 +4306,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
$graph_stats = get_statwin_graph_statistics($chart, $series_suffix);
// Fix event and alert scale
$max_value = 1;
foreach ($chart as $timestamp => $chart_data) {
if ($show_events) {
if ($chart_data['event'.$series_suffix] > 0) {
@ -4285,7 +4324,6 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
}
}
}
///////////////////////////////////////////////////
if(!$fullscale){
// Set the title and time format
@ -4366,7 +4404,7 @@ function fullscale_data ( &$chart_data, &$chart_extra_data, &$long_index,
$events = false, $show_events = false,
$show_unknown = false, $show_alerts = false,
$series_suffix = '', $percentil = false,
$flash_chart = true ){
$flash_chart = true, $boolean_graph = false){
global $config;
global $max_value;
@ -4504,7 +4542,13 @@ function fullscale_data ( &$chart_data, &$chart_extra_data, &$long_index,
}
$series_type['event'.$series_suffix] = 'points';
$series_type['alert'.$series_suffix] = 'points';
$series_type['unknown'.$series_suffix] = 'area';
$series_type['unknown'.$series_suffix] = 'unknown';
if($boolean_graph){
$series_type['sum'.$series_suffix] = 'boolean';
}
else{
$series_type['sum'.$series_suffix] = 'area';
}
}
function grafico_modulo_boolean ($agent_module_id, $period, $show_events,

View File

@ -942,6 +942,7 @@ function pandoraFlotArea(graph_id, values, labels, labels_long, legend,
filled = false;
steps_chart = false
break;
case 'unknown':
case 'boolean':
line_show = true;
points_show = false;

View File

@ -338,7 +338,7 @@ function flot_area_graph($chart_data, $width, $height, $color, $legend,
}
foreach ($chart_data as $label => $values) {
$labels[] = io_safe_output($label);
$labels[] = $label;
foreach($values as $key => $value) {
$jsvar = "data_" . $graph_id . "_" . $key;
@ -716,7 +716,7 @@ function flot_hcolumn_chart ($graph_data, $width, $height, $water_mark, $font =
$data = array();
foreach ($graph_data as $label => $values) {
$labels[] = io_safe_output($label);
$labels[] = $label;
$i--;
foreach ($values as $key => $value) {
@ -818,7 +818,7 @@ function flot_vcolumn_chart ($graph_data, $width, $height, $color, $legend, $lon
$max = 0;
$i = count($graph_data);
foreach ($graph_data as $label => $values) {
$labels[] = io_safe_output($label);
$labels[] = $label;
$i--;
foreach ($values as $key => $value) {
@ -942,7 +942,7 @@ function flot_slicesbar_graph ($graph_data, $period, $width, $height, $legend, $
$c = 0;
$acumulate_data = array();
foreach ($graph_data as $label => $values) {
$labels[] = io_safe_output($label);
$labels[] = $label;
$i--;
foreach ($values as $key => $value) {

View File

@ -0,0 +1,148 @@
<?php
/*
* @package Include/help/es/
*/
?>
<style type="text/css">
* {
font-family: 'lato-bolder';
font-size: 1em;
}
img.hlp_graphs {
width: 80%;
max-width: 800px;
min-width: 400px;
margin: 15px auto;
display: block;
}
ul.clean {
list-style-type: none;
}
p,u,i,b {
font-family: 'lato-bolder';
}
b {
font-size: 0.90em!important;
}
dl dt {
margin-top: 1em;
font-weight: bold;
}
dl {
margin-bottom: 2em;
}
div.img_title {
text-align: center;
font-size: 0.8em;
font-style: italic;
width: 100%;
margin-top: 4em;
}
</style>
<body class="hlp_graphs">
<h1>INTERPRETING GHRAPHS IN PANDORA FMS</h1>
<p>In Pandora FMS, graphs represent the values a module has had during a given period.</p>
<p>Due to the large amount of data that Pandora FMS stores, two different types of functionality are offered</p>
<h2>NORMAL GRAPHS</h2>
<img class="hlp_graphs" src="<?php echo $config["homeurl"];?>images/help/chart_normal_sample.png" alt="regular chart sample" />
<h4>General characteristics</h4>
<p>These are graphs that represent the information stored by the module at a basic level.</p>
<p>They allow us to see an approximation of the values in which our module oscillates.</p>
<p>The module data are divided into <i>boxes</i> in such a way that a sample of the module values is represented, <b>not all values are shown</b>. This is complemented by dividing the view into three graphs, <b>Max</b> (maximum values), <b>min</b> (minimum values) and <b>avg</b> (average values)</p>
<ul class="clean">
<li><b>Advantages</b>: They are generated very quickly without consuming hardly any resources.</li>
<li><b>Disadvantages</b>: The information provided is approximate. The status of the monitors they represent are calculated on an event-driven basis.</li>
<h4>Display options</h4>
<dl>
<dt>Refresh time</dt>
<dd>Time the graph will take to be created again.</dd>
<dt>Avg. Only</dt>
<dd>Only the averages graph will be created.</dd>
<dt>Starting date</dt>
<dd>Date until which the graphic will be created.</dd>
<dt>Startup time</dt>
<dd>Hour minutes and seconds until the graphic is created.</dd>
<dt>Zoom factor</dt>
<dd>Graph viewfinder size, multiplicative.</dd>
<dt>Time Range</dt>
<dd>Sets the time period from which data will be collected.</dd>
<dt>Show events</dt>
<dd>Displays indicator points with event information at the top.</dd>
<dt>Show alerts</dt>
<dd>Shows indicator points with triggered alert information at the top.</dd>
<dt>Show percentile</dt>
<dd>Adds a graph that indicates the percentile line (configurable in general visual options of Pandora).</dd>
<dt>Time comparison (superimposed)</dt>
<dd>Displays the same graphic overlay, but in the period before the selected one. For example, if we request a period of one week and activate this option, the week before the chosen one will also be shown superimposed.</dd>
<dt>Time comparison (independent)</dt>
<dd>Displays the same graph, but in the period before the selected one, in a separate area. For example, if we request a period of one week and activate this option, the week before the chosen one will also be shown.</dd>
<dt>Display unknown graphic</dt>
<dd>It shows boxes in grey shading covering the periods in which Pandora FMS cannot guarantee the module's status, either due to data loss, disconnection of a software agent, etc.</dd>
<dt>Show Full Scale Graph (TIP)</dt>
<dd>Switches the creation mode from "normal" to "TIP". In this mode, the graphs will show real data rather than approximations, so the time it will take to generate them will be longer. More detailed information on this type of graphs can be found in the following section.</dd>
</dl>
<br />
<br />
<h2>TIP GRAPS</h2>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_tip_sample.png" alt="TIP chart sample" />
<h4>General characteristics</h4>
<p>These are graphs that represent <b>real data</b>.</p>
<p>They show us a true representation of the data reported by our module.</p>
<p>As these are real data, it will not be necessary to supplement the information with extra graphs (avg, min, max).</p>
<p>The calculation of periods in unknown state is supported by events, such as normal graphs, but is complemented by extra detection if there is any.</p>
<p>Examples of resolution offered by normal and TIP methods:</p>
<div class="img_title">Example of normal graph in unknown interval</div>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_normal_detail.png" alt="TIP chart detail" />
<div class="img_title">Example of TIP graph in unknown interval</div>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_tip_detail.png" alt="TIP chart detail" />
<br />
<ul class="clean">
<li><b>Advantages</b>: The data represented are real data. This is the most realistic way to review module data.</li>
<li><b>Disadvantages</b>: Processing is slower than in normal graphs. Depending on the time range and the volume of data to be displayed, your display may be less fluid.</li>
</ul>
</body>

View File

@ -0,0 +1,148 @@
<?php
/*
* @package Include/help/es/
*/
?>
<style type="text/css">
* {
font-family: 'lato-bolder';
font-size: 1em;
}
img.hlp_graphs {
width: 80%;
max-width: 800px;
min-width: 400px;
margin: 15px auto;
display: block;
}
ul.clean {
list-style-type: none;
}
p,u,i,b {
font-family: 'lato-bolder';
}
b {
font-size: 0.90em!important;
}
dl dt {
margin-top: 1em;
font-weight: bold;
}
dl {
margin-bottom: 2em;
}
div.img_title {
text-align: center;
font-size: 0.8em;
font-style: italic;
width: 100%;
margin-top: 4em;
}
</style>
<body class="hlp_graphs">
<h1>Interpretar las gr&aacute;ficas en Pandora FMS</h1>
<p>Las gr&aacute;ficas en Pandora representan los valores que un m&oacute;dulo ha tenido a lo largo de un período.</p>
<p>Debido a la gran cantidad de datos que Pandora FMS almacena, se ofrecen dos tipos diferentes de funcionalidad:</p>
<h2>Gr&aacute;ficas Normales</h2>
<img class="hlp_graphs" src="<?php echo $config["homeurl"];?>images/help/chart_normal_sample.png" alt="regular chart sample" />
<h4>Caracter&iacute;sticas generales</h4>
<p>Son gr&aacute;ficas que representan la informaci&oacute;n almacenada por el m&oacute;dulo a un nivel b&aacute;sico.</p>
<p>Nos permite ver una aproximaci&oacute;n de los valores en los que oscila nuestro m&oacute;dulo.</p>
<p>Dividen los datos del m&oacute;dulo en <i>cajas</i> de tal manera que se representa una muestra de los valores del m&oacute;dulo, <b>no se pintan todos los valores</b>. Esta carencia se complementa dividiendo la vista en tres gr&aacute;ficas, <b>Max</b> (valores m&aacute;ximos), <b>min</b> (valores m&iacute;nimos) y <b>avg</b> (valores promedios)</p>
<ul class="clean">
<li><b>Ventajas</b>: Se generan muy r&aacute;pidamente sin consumir apenas recursos.</li>
<li><b>Inconvenientes</b>: La informaci&oacute;n que proveen es aproximada. Los estados de los monitores que representan se calculan en base a eventos.</li>
<h4>Opciones de visualizaci&oacute;n</h4>
<dl>
<dt>Tiempo de refresco</dt>
<dd>Tiempo en que se pintar&aacute; la gr&aacute;fica de nuevo.</dd>
<dt>Avg. Only</dt>
<dd>Solo se pintar&aacute; la gr&aacute;fica de promedios.</dd>
<dt>Fecha de inicio</dt>
<dd>Fecha hasta la que se pintar&aacute; la gr&aacute;fica.</dd>
<dt>Tiempo de inicio</dt>
<dd>Hora minutos y segundos hasta los que se pintar&aacute; la gr&aacute;fica.</dd>
<dt>Factor de zoom</dt>
<dd>Tama&ntilde;o del visor de la gr&aacute;fica, multiplicativo.</dd>
<dt>Rango de tiempo</dt>
<dd>Establece el per&iacute;odo de tiempo desde el que se recoger&aacute;n los datos.</dd>
<dt>Mostrar eventos</dt>
<dd>Muestra puntos indicadores con la informaci&oacute;n de eventos en la parte superior.</dd>
<dt>Mostrar alertas</dt>
<dd>Muestra puntos indicadores con la informaci&oacute;n de alertas disparadas en la parte superior.</dd>
<dt>Mostrar percentil</dt>
<dd>Agrega una gr&aacute;fica que indica la l&iacute;nea del percentil (configurable en opciones visuales generales de Pandora).</dd>
<dt>Comparaci&oacute;n de tiempo (superpuesto)</dt>
<dd>Muestra superpuesta la misma gr&aacute;fica, pero en el per&iacute;odo anterior al seleccionado. Por ejemplo, si solicitamos un per&iacute;odo de una semana y activamos esta opci&oacute;n, la semana anterior a la elegida tambi&eacute;n se mostrar&aacute; superpuesta.</dd>
<dt>Comparaci&oacute;n de tiempo (independiente)</dt>
<dd>Muestra la misma gr&aacute;fica, pero en el per&iacute;odo anterior al seleccionado, en un area independiente. Por ejemplo, si solicitamos un per&iacute;odo de una semana y activamos esta opci&oacute;n, la semana anterior a la elegida tambi&eacute;n se mostrar&aacute;.</dd>
<dt>Mostrar gr&aacute;fica de desconocidos</dt>
<dd>Muestra cajas en sombreado gris cubriendo los per&iacute;odos en que Pandora FMS no puede garantizar el estado del m&oacute;dulo, ya sea por p&eacute;rdida de datos, desconexi&oacute;n de un agente software, etc.</dd>
<dt>Mostrar gr&aacute;fica de escala completa (TIP)</dt>
<dd>Cambia el modo de pintado de "normal" a "TIP". En este modo, las gr&aacute;ficas mostrar&aacute;n datos reales en vez de aproximaciones, por lo que el tiempo que emplear&aacute;n para su generaci&oacute;n ser&aacute; mayor. Podr&aacute; encontrar informaci&oacute;n m&aacute;s detallada de este tipo de gr&aacute;ficas en el siguiente apartado.</dd>
</dl>
<br />
<br />
<h2>Gr&aacute;ficas TIP</h2>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_tip_sample.png" alt="TIP chart sample" />
<h4>Caracter&iacute;sticas generales</h4>
<p>Son gr&aacute;ficas que representan <b>datos reales</b>.</p>
<p>Nos muestra una representaci&oacute;n veraz de los datos reportados por nuestro m&oacute;dulo.</p>
<p>Al ser datos reales no ser&aacute; necesario complementar la informaci&oacute;n con gr&aacute;ficas extra (avg,min,max).</p>
<p>El c&aacute;lculo de per&iacute;odos en estado desconocido se apoya en eventos, tal y como funcionan las gr&aacute;ficas normales, pero se complementa con una detecci&oacute;n extra en caso de haberlos.</p>
<p>Ejemplos de resoluci&oacute;n ofrecidas por metodos normal y TIP:</p>
<div class="img_title">Ejemplo de gr&aacute;fica normal en intervalo desconocido</div>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_normal_detail.png" alt="TIP chart detail" />
<div class="img_title">Ejemplo de gr&aacute;fica TIP en intervalo desconocido</div>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_tip_detail.png" alt="TIP chart detail" />
<br />
<ul class="clean">
<li><b>Ventajas</b>: Los datos representados son datos reales. Es la forma m&aacute;s realista de revisar los datos de un m&oacute;dulo.</li>
<li><b>Inconvenientes</b>: Su procesado es m&aacute;s lento que en las gr&aacute;ficas normales. Dependiendo del rango de tiempo y el volumen de datos a mostrar es posible que su visualizaci&oacute;n sea menos flu&iacute;da.</li>
</ul>
</body>

View File

@ -0,0 +1,148 @@
<?php
/*
* @package Include/help/es/
*/
?>
<style type="text/css">
* {
font-family: 'lato-bolder';
font-size: 1em;
}
img.hlp_graphs {
width: 80%;
max-width: 800px;
min-width: 400px;
margin: 15px auto;
display: block;
}
ul.clean {
list-style-type: none;
}
p,u,i,b {
font-family: 'lato-bolder';
}
b {
font-size: 0.90em!important;
}
dl dt {
margin-top: 1em;
font-weight: bold;
}
dl {
margin-bottom: 2em;
}
div.img_title {
text-align: center;
font-size: 0.8em;
font-style: italic;
width: 100%;
margin-top: 4em;
}
</style>
<body class="hlp_graphs">
<h1>INTERPRETING GHRAPHS IN PANDORA FMS</h1>
<p>In Pandora FMS, graphs represent the values a module has had during a given period.</p>
<p>Due to the large amount of data that Pandora FMS stores, two different types of functionality are offered</p>
<h2>NORMAL GRAPHS</h2>
<img class="hlp_graphs" src="<?php echo $config["homeurl"];?>images/help/chart_normal_sample.png" alt="regular chart sample" />
<h4>General characteristics</h4>
<p>These are graphs that represent the information stored by the module at a basic level.</p>
<p>They allow us to see an approximation of the values in which our module oscillates.</p>
<p>The module data are divided into <i>boxes</i> in such a way that a sample of the module values is represented, <b>not all values are shown</b>. This is complemented by dividing the view into three graphs, <b>Max</b> (maximum values), <b>min</b> (minimum values) and <b>avg</b> (average values)</p>
<ul class="clean">
<li><b>Advantages</b>: They are generated very quickly without consuming hardly any resources.</li>
<li><b>Disadvantages</b>: The information provided is approximate. The status of the monitors they represent are calculated on an event-driven basis.</li>
<h4>Display options</h4>
<dl>
<dt>Refresh time</dt>
<dd>Time the graph will take to be created again.</dd>
<dt>Avg. Only</dt>
<dd>Only the averages graph will be created.</dd>
<dt>Starting date</dt>
<dd>Date until which the graphic will be created.</dd>
<dt>Startup time</dt>
<dd>Hour minutes and seconds until the graphic is created.</dd>
<dt>Zoom factor</dt>
<dd>Graph viewfinder size, multiplicative.</dd>
<dt>Time Range</dt>
<dd>Sets the time period from which data will be collected.</dd>
<dt>Show events</dt>
<dd>Displays indicator points with event information at the top.</dd>
<dt>Show alerts</dt>
<dd>Shows indicator points with triggered alert information at the top.</dd>
<dt>Show percentile</dt>
<dd>Adds a graph that indicates the percentile line (configurable in general visual options of Pandora).</dd>
<dt>Time comparison (superimposed)</dt>
<dd>Displays the same graphic overlay, but in the period before the selected one. For example, if we request a period of one week and activate this option, the week before the chosen one will also be shown superimposed.</dd>
<dt>Time comparison (independent)</dt>
<dd>Displays the same graph, but in the period before the selected one, in a separate area. For example, if we request a period of one week and activate this option, the week before the chosen one will also be shown.</dd>
<dt>Display unknown graphic</dt>
<dd>It shows boxes in grey shading covering the periods in which Pandora FMS cannot guarantee the module's status, either due to data loss, disconnection of a software agent, etc.</dd>
<dt>Show Full Scale Graph (TIP)</dt>
<dd>Switches the creation mode from "normal" to "TIP". In this mode, the graphs will show real data rather than approximations, so the time it will take to generate them will be longer. More detailed information on this type of graphs can be found in the following section.</dd>
</dl>
<br />
<br />
<h2>TIP GRAPS</h2>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_tip_sample.png" alt="TIP chart sample" />
<h4>General characteristics</h4>
<p>These are graphs that represent <b>real data</b>.</p>
<p>They show us a true representation of the data reported by our module.</p>
<p>As these are real data, it will not be necessary to supplement the information with extra graphs (avg, min, max).</p>
<p>The calculation of periods in unknown state is supported by events, such as normal graphs, but is complemented by extra detection if there is any.</p>
<p>Examples of resolution offered by normal and TIP methods:</p>
<div class="img_title">Example of normal graph in unknown interval</div>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_normal_detail.png" alt="TIP chart detail" />
<div class="img_title">Example of TIP graph in unknown interval</div>
<img class="hlp_graphs "src="<?php echo $config["homeurl"];?>images/help/chart_tip_detail.png" alt="TIP chart detail" />
<br />
<ul class="clean">
<li><b>Advantages</b>: The data represented are real data. This is the most realistic way to review module data.</li>
<li><b>Disadvantages</b>: Processing is slower than in normal graphs. Depending on the time range and the volume of data to be displayed, your display may be less fluid.</li>
</ul>
</body>

View File

@ -106,7 +106,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent);
</head>
<body bgcolor="#ffffff" style='background:#ffffff;'>
<?php
// Module id
$id = (int) get_parameter ("id", 0);
// Agent id
@ -286,7 +286,7 @@ $alias = db_get_value ("alias","tagente","id_agente",$id_agent);
$params = array();
// TOP TEXT
//Use the no_meta parameter because this image is only in the base console
$params['top_text'] = "<div style='color: white; width: 100%; text-align: center; font-weight: bold; vertical-align: top;'>" . html_print_image('images/wrench_blanco.png', true, array('width' => '16px'), false, false, true) . ' ' . __('Pandora FMS Graph configuration menu') . "</div>";
$params['top_text'] = "<div style='color: white; width: 100%; text-align: center; font-weight: bold; vertical-align: top;'>" . html_print_image('images/wrench_blanco.png', true, array('width' => '16px'), false, false, true) . ' ' . __('Pandora FMS Graph configuration menu') . ui_print_help_icon ("graphs",true, $config["homeurl"], "images/help_w.png") . "</div>";
$params['body_text'] = "<div class='menu_sidebar_outer'>";
$params['body_text'] .=__('Please, make your changes and apply with the <i>Reload</i> button');