Fixed the charts (boolean and sparse) added lost time interval. TICKET: #2511

This commit is contained in:
mdtrooper 2015-08-24 17:08:39 +02:00
parent 8514212e69
commit 88fa70ad87
1 changed files with 20 additions and 6 deletions

View File

@ -250,9 +250,12 @@ function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_i
// Calculate chart data // Calculate chart data
$last_known = $previous_data; $last_known = $previous_data;
for ($i = 0; $i < $resolution; $i++) {
for ($i = 0; $i <= $resolution; $i++) {
$timestamp = $datelimit + ($interval * $i); $timestamp = $datelimit + ($interval * $i);
$total = 0; $total = 0;
$count = 0; $count = 0;
@ -510,6 +513,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$flash_chart = $config['flash_charts']; $flash_chart = $config['flash_charts'];
// Get event data (contains alert data too) // Get event data (contains alert data too)
$events = array(); $events = array();
if ($show_unknown == 1 || $show_events == 1 || $show_alerts == 1) { if ($show_unknown == 1 || $show_events == 1 || $show_alerts == 1) {
@ -542,6 +546,7 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
'order' => 'utimestamp ASC'), 'order' => 'utimestamp ASC'),
array ('datos', 'utimestamp'), 'AND', $search_in_history_db); array ('datos', 'utimestamp'), 'AND', $search_in_history_db);
// Get module warning_min and critical_min // Get module warning_min and critical_min
$warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$agent_module_id); $warning_min = db_get_value('min_warning','tagente_modulo','id_agente_modulo',$agent_module_id);
$critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$agent_module_id); $critical_min = db_get_value('min_critical','tagente_modulo','id_agente_modulo',$agent_module_id);
@ -610,7 +615,9 @@ function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
if ($baseline) { if ($baseline) {
$baseline_data = array (); $baseline_data = array ();
if ($baseline == 1) { if ($baseline == 1) {
$baseline_data = enterprise_hook ('reporting_enterprise_get_baseline', array ($agent_module_id, $period, $width, $height , $title, $unit_name, $date)); $baseline_data = enterprise_hook(
'reporting_enterprise_get_baseline',
array ($agent_module_id, $period, $width, $height , $title, $unit_name, $date));
if ($baseline_data === ENTERPRISE_NOT_HOOK) { if ($baseline_data === ENTERPRISE_NOT_HOOK) {
$baseline_data = array (); $baseline_data = array ();
} }
@ -741,6 +748,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$series_suffix_str = ' (' . __('Previous') . ')'; $series_suffix_str = ' (' . __('Previous') . ')';
// Build the data of the previous period // Build the data of the previous period
grafico_modulo_sparse_data ($agent_module_id, $period, $show_events, grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
$width, $height, $title, $unit_name, $width, $height, $title, $unit_name,
$show_alerts, $avg_only, $show_alerts, $avg_only,
@ -748,6 +757,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$projection, $adapt_key, $compare, $projection, $adapt_key, $compare,
$series_suffix, $series_suffix_str, $show_unknown); $series_suffix, $series_suffix_str, $show_unknown);
switch ($compare) { switch ($compare) {
case 'separated': case 'separated':
// Store the chart calculated // Store the chart calculated
@ -771,6 +782,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
} }
} }
// Build the data of the current period // Build the data of the current period
$data_returned = grafico_modulo_sparse_data ($agent_module_id, $data_returned = grafico_modulo_sparse_data ($agent_module_id,
$period, $show_events, $period, $show_events,
@ -779,6 +791,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$date, $unit, $baseline, $return_data, $show_title, $date, $unit, $baseline, $return_data, $show_title,
$projection, $adapt_key, $compare, '', '', $show_unknown); $projection, $adapt_key, $compare, '', '', $show_unknown);
if ($return_data) { if ($return_data) {
return $data_returned; return $data_returned;
} }
@ -802,7 +815,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
} }
$water_mark = array('file' => $water_mark = array('file' =>
$config['homedir'] . "/images/logo_vertical_water.png", $config['homedir'] . "/images/logo_vertical_water.png",
'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false)); 'url' => ui_get_full_url("images/logo_vertical_water.png", false, false, false));
if ($compare === 'separated') { if ($compare === 'separated') {
@ -820,6 +833,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
} }
else { else {
// Color commented not to restrict serie colors // Color commented not to restrict serie colors
return area_graph($flash_chart, $chart, $width, $height, $color, $legend, return area_graph($flash_chart, $chart, $width, $height, $color, $legend,
$long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false), $long_index, ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl, "", $unit, $homeurl, $water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl,
@ -2935,7 +2949,7 @@ function grafico_modulo_boolean_data ($agent_module_id, $period, $show_events,
// Calculate chart data // Calculate chart data
$last_known = $previous_data; $last_known = $previous_data;
for ($i = 0; $i < $resolution; $i++) { for ($i = 0; $i <= $resolution; $i++) {
$timestamp = $datelimit + ($interval * $i); $timestamp = $datelimit + ($interval * $i);
$zero = 0; $zero = 0;