mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
2012-08-30 Sergio Martin <sergio.martin@artica.es>
* include/functions_graph.php operation/agentes/stat_win.php: Added time compare mode to sparse module graphs git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6922 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
2695f5f54c
commit
476bf9fcc0
@ -1,3 +1,9 @@
|
|||||||
|
2012-08-30 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
|
* include/functions_graph.php
|
||||||
|
operation/agentes/stat_win.php: Added time compare mode
|
||||||
|
to sparse module graphs
|
||||||
|
|
||||||
2012-08-29 Sergio Martin <sergio.martin@artica.es>
|
2012-08-29 Sergio Martin <sergio.martin@artica.es>
|
||||||
|
|
||||||
* include/styles/pandora_legacy.css
|
* include/styles/pandora_legacy.css
|
||||||
|
@ -25,16 +25,204 @@ define("GRAPH_STACKED_AREA", 1);
|
|||||||
define("GRAPH_LINE", 2);
|
define("GRAPH_LINE", 2);
|
||||||
define("GRAPH_STACKED_LINE", 3);
|
define("GRAPH_STACKED_LINE", 3);
|
||||||
|
|
||||||
function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
function grafico_modulo_sparse_data_chart (&$chart, &$chart_data_extra, &$long_index,
|
||||||
$width, $height , $title = '', $unit_name = null,
|
$data, $data_i, $resolution, $interval, $period, $datelimit, $flash_chart,
|
||||||
$show_alerts = false, $avg_only = 0, $pure = false,
|
$projection, $avg_only = false, $uncompressed_module = false,
|
||||||
$date = 0, $unit = '', $baseline = 0, $return_data = 0, $show_title = true,
|
$show_events = false, $show_alerts = false, $baseline = false,
|
||||||
$only_image = false, $homeurl = '', $ttl = 1, $projection = false, $adapt_key = '') {
|
$baseline_data = array(), $events = array(), $series_suffix = '') {
|
||||||
|
|
||||||
global $config;
|
global $config;
|
||||||
global $graphic_type;
|
// Event iterator
|
||||||
|
$event_i = 0;
|
||||||
|
|
||||||
enterprise_include_once("include/functions_reporting.php");
|
// Calculate chart data
|
||||||
|
for ($i = 0; $i < $resolution; $i++) {
|
||||||
|
$timestamp = $datelimit + ($interval * $i);
|
||||||
|
|
||||||
|
$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)) {
|
||||||
|
if ($interval_min === false) {
|
||||||
|
$interval_min = $data[$data_i]['datos'];
|
||||||
|
}
|
||||||
|
if ($interval_max === false) {
|
||||||
|
$interval_max = $data[$data_i]['datos'];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data[$data_i]['datos'] > $interval_max) {
|
||||||
|
$interval_max = $data[$data_i]['datos'];
|
||||||
|
} else if ($data[$data_i]['datos'] < $interval_min) {
|
||||||
|
$interval_min = $data[$data_i]['datos'];
|
||||||
|
}
|
||||||
|
$total += $data[$data_i]['datos'];
|
||||||
|
$count++;
|
||||||
|
$data_i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Data in the interval
|
||||||
|
if ($count > 0) {
|
||||||
|
$total /= $count;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read events and alerts that fall in the current interval
|
||||||
|
$event_value = 0;
|
||||||
|
$alert_value = 0;
|
||||||
|
$event_ids = array();
|
||||||
|
$alert_ids = array();
|
||||||
|
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'];
|
||||||
|
}
|
||||||
|
if ($show_alerts == 1 && substr ($events[$event_i]['event_type'], 0, 5) == 'alert') {
|
||||||
|
$alert_value++;
|
||||||
|
$alert_ids[] = $events[$event_i]['id_evento'];
|
||||||
|
}
|
||||||
|
$event_i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$flash_chart) {
|
||||||
|
// Set the title and time format
|
||||||
|
if ($period <= 21600) {
|
||||||
|
$time_format = 'H:i:s';
|
||||||
|
}
|
||||||
|
elseif ($period < 86400) {
|
||||||
|
$time_format = 'H:i';
|
||||||
|
}
|
||||||
|
elseif ($period < 1296000) {
|
||||||
|
$time_format = "M \nd H:i";
|
||||||
|
}
|
||||||
|
elseif ($period < 2592000) {
|
||||||
|
$time_format = "M \nd H\h";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$time_format = "M \nd H\h";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// Set the title and time format
|
||||||
|
if ($period <= 21600) {
|
||||||
|
$time_format = 'H:i:s';
|
||||||
|
}
|
||||||
|
elseif ($period < 86400) {
|
||||||
|
$time_format = 'H:i';
|
||||||
|
}
|
||||||
|
elseif ($period < 1296000) {
|
||||||
|
$time_format = "M d H:i";
|
||||||
|
}
|
||||||
|
elseif ($period < 2592000) {
|
||||||
|
$time_format = "M d H\h";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$time_format = "M d H\h";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$timestamp_short = date($time_format, $timestamp);
|
||||||
|
$long_index[$timestamp_short] = date(
|
||||||
|
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
|
||||||
|
if (!$projection){
|
||||||
|
$timestamp = $timestamp_short;
|
||||||
|
}
|
||||||
|
// Data
|
||||||
|
if($show_events) {
|
||||||
|
$chart[$timestamp]['event'.$series_suffix] = $event_value;
|
||||||
|
$series_type['event'.$series_suffix] = 'points';
|
||||||
|
}
|
||||||
|
if($show_alerts) {
|
||||||
|
$chart[$timestamp]['alert'.$series_suffix] = $alert_value;
|
||||||
|
$chart[$timestamp]['alert'.$series_suffix] = $alert_value;
|
||||||
|
$chart[$timestamp]['alert'.$series_suffix] = $alert_value;
|
||||||
|
$series_type['alert'.$series_suffix] = 'points';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($count > 0) {
|
||||||
|
if ($avg_only) {
|
||||||
|
$chart[$timestamp]['sum'.$series_suffix] = $total;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$chart[$timestamp]['max'.$series_suffix] = $interval_max;
|
||||||
|
$chart[$timestamp]['sum'.$series_suffix] = $total;
|
||||||
|
$chart[$timestamp]['min'.$series_suffix] = $interval_min;
|
||||||
|
}
|
||||||
|
$previous_data = $total;
|
||||||
|
// Compressed data
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($uncompressed_module || ($timestamp > time ())) {
|
||||||
|
if ($avg_only) {
|
||||||
|
$chart[$timestamp]['sum'.$series_suffix] = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$chart[$timestamp]['max'.$series_suffix] = 0;
|
||||||
|
$chart[$timestamp]['sum'.$series_suffix] = 0;
|
||||||
|
$chart[$timestamp]['min'.$series_suffix] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($avg_only) {
|
||||||
|
$chart[$timestamp]['sum'.$series_suffix] = $previous_data;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$chart[$timestamp]['max'.$series_suffix] = $previous_data;
|
||||||
|
$chart[$timestamp]['sum'.$series_suffix] = $previous_data;
|
||||||
|
$chart[$timestamp]['min'.$series_suffix] = $previous_data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//$chart[$timestamp]['count'] = 0;
|
||||||
|
/////////
|
||||||
|
//$chart[$timestamp]['timestamp_bottom'] = $timestamp;
|
||||||
|
//$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
|
||||||
|
/////////
|
||||||
|
|
||||||
|
if ($baseline) {
|
||||||
|
$chart[$timestamp]['baseline'.$series_suffix] = array_shift ($baseline_data);
|
||||||
|
if ($chart[$timestamp]['baseline'.$series_suffix] == NULL) {
|
||||||
|
$chart[$timestamp]['baseline'.$series_suffix] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!empty($event_ids)) {
|
||||||
|
$chart_extra_data[count($chart)-1]['events'.$series_suffix] = implode(',',$event_ids);
|
||||||
|
}
|
||||||
|
if(!empty($alert_ids)) {
|
||||||
|
$chart_extra_data[count($chart)-1]['alerts'.$series_suffix] = implode(',',$alert_ids);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
||||||
|
$width, $height , $title = '', $unit_name = null,
|
||||||
|
$show_alerts = false, $avg_only = 0, $date = 0, $unit = '',
|
||||||
|
$baseline = 0, $return_data = 0, $show_title = true, $projection = false,
|
||||||
|
$adapt_key = '', $compare = false, $series_suffix = '', $series_suffix_str = '') {
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
global $chart;
|
||||||
|
global $color;
|
||||||
|
global $legend;
|
||||||
|
global $long_index;
|
||||||
|
global $series_type;
|
||||||
|
global $chart_extra_data;
|
||||||
|
global $warning_min;
|
||||||
|
global $critical_min;
|
||||||
|
|
||||||
|
$chart = array();
|
||||||
|
$color = array();
|
||||||
|
$legend = array();
|
||||||
|
$long_index = array();
|
||||||
|
$series_type = array();
|
||||||
|
$chart_extra_data = array();
|
||||||
|
$warning_min = 0;
|
||||||
|
$critical_min = 0;
|
||||||
|
|
||||||
// Set variables
|
// Set variables
|
||||||
if ($date == 0) $date = get_system_time();
|
if ($date == 0) $date = get_system_time();
|
||||||
@ -126,16 +314,12 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Data iterator
|
// Data iterator
|
||||||
$j = 0;
|
$data_i = 0;
|
||||||
|
|
||||||
// Event iterator
|
|
||||||
$k = 0;
|
|
||||||
|
|
||||||
// Set initial conditions
|
// Set initial conditions
|
||||||
$chart = array();
|
|
||||||
if ($data[0]['utimestamp'] == $datelimit) {
|
if ($data[0]['utimestamp'] == $datelimit) {
|
||||||
$previous_data = $data[0]['datos'];
|
$previous_data = $data[0]['datos'];
|
||||||
$j++;
|
$data_i++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$previous_data = 0;
|
$previous_data = 0;
|
||||||
@ -156,167 +340,12 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||||||
$unit = modules_get_unit($agent_module_id);
|
$unit = modules_get_unit($agent_module_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
$chart_extra_data = array();
|
|
||||||
$series_type = array();
|
|
||||||
|
|
||||||
// Calculate chart data
|
// Calculate chart data
|
||||||
for ($i = 0; $i < $resolution; $i++) {
|
grafico_modulo_sparse_data_chart ($chart, $chart_data_extra, $long_index,
|
||||||
$timestamp = $datelimit + ($interval * $i);
|
$data, $data_i, $resolution, $interval, $period, $datelimit, $flash_chart,
|
||||||
|
$projection, $avg_only, $uncompressed_module,
|
||||||
$total = 0;
|
$show_events, $show_alerts, $baseline,
|
||||||
$count = 0;
|
$baseline_data, $events, $series_suffix);
|
||||||
|
|
||||||
// Read data that falls in the current interval
|
|
||||||
$interval_min = false;
|
|
||||||
$interval_max = false;
|
|
||||||
while (isset ($data[$j]) && $data[$j]['utimestamp'] >= $timestamp && $data[$j]['utimestamp'] < ($timestamp + $interval)) {
|
|
||||||
if ($interval_min === false) {
|
|
||||||
$interval_min = $data[$j]['datos'];
|
|
||||||
}
|
|
||||||
if ($interval_max === false) {
|
|
||||||
$interval_max = $data[$j]['datos'];
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($data[$j]['datos'] > $interval_max) {
|
|
||||||
$interval_max = $data[$j]['datos'];
|
|
||||||
} else if ($data[$j]['datos'] < $interval_min) {
|
|
||||||
$interval_min = $data[$j]['datos'];
|
|
||||||
}
|
|
||||||
$total += $data[$j]['datos'];
|
|
||||||
$count++;
|
|
||||||
$j++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Data in the interval
|
|
||||||
if ($count > 0) {
|
|
||||||
$total /= $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read events and alerts that fall in the current interval
|
|
||||||
$event_value = 0;
|
|
||||||
$alert_value = 0;
|
|
||||||
$event_ids = array();
|
|
||||||
$alert_ids = array();
|
|
||||||
while (isset ($events[$k]) && $events[$k]['utimestamp'] >= $timestamp && $events[$k]['utimestamp'] <= ($timestamp + $interval)) {
|
|
||||||
if ($show_events == 1) {
|
|
||||||
$event_value++;
|
|
||||||
$event_ids[] = $events[$k]['id_evento'];
|
|
||||||
}
|
|
||||||
if ($show_alerts == 1 && substr ($events[$k]['event_type'], 0, 5) == 'alert') {
|
|
||||||
$alert_value++;
|
|
||||||
$alert_ids[] = $events[$k]['id_evento'];
|
|
||||||
}
|
|
||||||
$k++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$flash_chart) {
|
|
||||||
// Set the title and time format
|
|
||||||
if ($period <= 21600) {
|
|
||||||
$time_format = 'H:i:s';
|
|
||||||
}
|
|
||||||
elseif ($period < 86400) {
|
|
||||||
$time_format = 'H:i';
|
|
||||||
}
|
|
||||||
elseif ($period < 1296000) {
|
|
||||||
$time_format = "M \nd H:i";
|
|
||||||
}
|
|
||||||
elseif ($period < 2592000) {
|
|
||||||
$time_format = "M \nd H\h";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$time_format = "M \nd H\h";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// Set the title and time format
|
|
||||||
if ($period <= 21600) {
|
|
||||||
$time_format = 'H:i:s';
|
|
||||||
}
|
|
||||||
elseif ($period < 86400) {
|
|
||||||
$time_format = 'H:i';
|
|
||||||
}
|
|
||||||
elseif ($period < 1296000) {
|
|
||||||
$time_format = "M d H:i";
|
|
||||||
}
|
|
||||||
elseif ($period < 2592000) {
|
|
||||||
$time_format = "M d H\h";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$time_format = "M d H\h";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$timestamp_short = date($time_format, $timestamp);
|
|
||||||
$long_index[$timestamp_short] = date(
|
|
||||||
html_entity_decode($config['date_format'], ENT_QUOTES, "UTF-8"), $timestamp);
|
|
||||||
if (!$projection){
|
|
||||||
$timestamp = $timestamp_short;
|
|
||||||
}
|
|
||||||
// Data
|
|
||||||
if($show_events) {
|
|
||||||
$chart[$timestamp]['event'] = $event_value;
|
|
||||||
$series_type['event'] = 'points';
|
|
||||||
}
|
|
||||||
if($show_alerts) {
|
|
||||||
$chart[$timestamp]['alert'] = $alert_value;
|
|
||||||
$series_type['alert'] = 'points';
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($count > 0) {
|
|
||||||
if ($avg_only) {
|
|
||||||
$chart[$timestamp]['sum'] = $total;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$chart[$timestamp]['max'] = $interval_max;
|
|
||||||
$chart[$timestamp]['sum'] = $total;
|
|
||||||
$chart[$timestamp]['min'] = $interval_min;
|
|
||||||
}
|
|
||||||
$previous_data = $total;
|
|
||||||
// Compressed data
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ($uncompressed_module || ($timestamp > time ())) {
|
|
||||||
if ($avg_only) {
|
|
||||||
$chart[$timestamp]['sum'] = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$chart[$timestamp]['max'] = 0;
|
|
||||||
$chart[$timestamp]['sum'] = 0;
|
|
||||||
$chart[$timestamp]['min'] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if ($avg_only) {
|
|
||||||
$chart[$timestamp]['sum'] = $previous_data;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$chart[$timestamp]['max'] = $previous_data;
|
|
||||||
$chart[$timestamp]['sum'] = $previous_data;
|
|
||||||
$chart[$timestamp]['min'] = $previous_data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//$chart[$timestamp]['count'] = 0;
|
|
||||||
/////////
|
|
||||||
//$chart[$timestamp]['timestamp_bottom'] = $timestamp;
|
|
||||||
//$chart[$timestamp]['timestamp_top'] = $timestamp + $interval;
|
|
||||||
/////////
|
|
||||||
|
|
||||||
if ($baseline) {
|
|
||||||
$chart[$timestamp]['baseline'] = array_shift ($baseline_data);
|
|
||||||
if ($chart[$timestamp]['baseline'] == NULL) {
|
|
||||||
$chart[$timestamp]['baseline'] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return chart data and don't draw
|
// Return chart data and don't draw
|
||||||
if ($return_data == 1) {
|
if ($return_data == 1) {
|
||||||
@ -331,55 +360,112 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||||||
// Fix event and alert scale
|
// Fix event and alert scale
|
||||||
$event_max = $max_value * 1.15;
|
$event_max = $max_value * 1.15;
|
||||||
foreach ($chart as $timestamp => $chart_data) {
|
foreach ($chart as $timestamp => $chart_data) {
|
||||||
if ($show_events && $chart_data['event'] > 0) {
|
if ($show_events && $chart_data['event'.$series_suffix] > 0) {
|
||||||
$chart[$timestamp]['event'] = $event_max * 1.15;
|
$chart[$timestamp]['event'.$series_suffix] = $event_max * 1.15;
|
||||||
}
|
}
|
||||||
if ($show_alerts && $chart_data['alert'] > 0) {
|
if ($show_alerts && $chart_data['alert'] > 0) {
|
||||||
$chart[$timestamp]['alert'] = $event_max;
|
$chart[$timestamp]['alert'.$series_suffix] = $event_max;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only show caption if graph is not small
|
// Only show caption if graph is not small
|
||||||
if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT)
|
if ($width > MIN_WIDTH_CAPTION && $height > MIN_HEIGHT)
|
||||||
//Flash chart
|
//Flash chart
|
||||||
$caption = __('Max. Value') . ': ' . $max_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value . ' ' . __('Units. Value') . ': ' . $unit;
|
$caption = __('Max. Value').$series_suffix_str . ': ' . $max_value . ' ' . __('Avg. Value').$series_suffix_str . ': ' . $avg_value . ' ' . __('Min. Value').$series_suffix_str . ': ' . $min_value . ' ' . __('Units. Value').$series_suffix_str . ': ' . $unit;
|
||||||
else
|
else
|
||||||
$caption = array();
|
$caption = array();
|
||||||
|
|
||||||
///////
|
///////
|
||||||
// Color commented not to restrict serie colors
|
// Color commented not to restrict serie colors
|
||||||
$color = array();
|
|
||||||
if($show_events) {
|
if($show_events) {
|
||||||
$color['event'] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
|
$color['event'.$series_suffix] = array('border' => '#ff0000', 'color' => '#ff0000', 'alpha' => 50);
|
||||||
}
|
}
|
||||||
if($show_alerts) {
|
if($show_alerts) {
|
||||||
$color['alert'] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
|
$color['alert'.$series_suffix] = array('border' => '#ff7f00', 'color' => '#ff7f00', 'alpha' => 50);
|
||||||
}
|
}
|
||||||
$color['max'] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
|
$color['max'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color3'], 'alpha' => 50);
|
||||||
$color['sum'] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
|
$color['sum'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color2'], 'alpha' => 50);
|
||||||
$color['min'] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
|
$color['min'.$series_suffix] = array('border' => '#000000', 'color' => $config['graph_color1'], 'alpha' => 50);
|
||||||
$color['baseline'] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
|
$color['baseline'.$series_suffix] = array('border' => null, 'color' => '#0097BD', 'alpha' => 10);
|
||||||
$color['unit'] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10);
|
$color['unit'.$series_suffix] = array('border' => null, 'color' => '#0097BC', 'alpha' => 10);
|
||||||
|
|
||||||
$legend = array();
|
|
||||||
if($show_events) {
|
if($show_events) {
|
||||||
$legend['event'] = __('Events');
|
$legend['event'.$series_suffix] = __('Events');
|
||||||
$chart_extra_data['legend_events'] = $legend['event'];
|
$chart_extra_data['legend_events'] = $legend['event'];
|
||||||
}
|
}
|
||||||
if($show_alerts) {
|
if($show_alerts) {
|
||||||
$legend['alert'] = __('Alerts');
|
$legend['alert'.$series_suffix] = __('Alerts');
|
||||||
$chart_extra_data['legend_alerts'] = $legend['alert'];
|
$chart_extra_data['legend_alerts'] = $legend['alert'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$avg_only){
|
if (!$avg_only){
|
||||||
$legend['max'] = __('Max') . ' (' .format_for_graph($max_value) . ') ' . $unit;
|
$legend['max'.$series_suffix] = __('Max').$series_suffix_str . ' (' .format_for_graph($max_value) . ') ' . $unit;
|
||||||
$legend['sum'] = __('Avg') . ' (' . $avg_value . ') ' . $unit;
|
$legend['sum'.$series_suffix] = __('Avg').$series_suffix_str . ' (' . $avg_value . ') ' . $unit;
|
||||||
$legend['min'] = __('Min') . ' (' . format_for_graph($min_value) . ') ' . $unit;
|
$legend['min'.$series_suffix] = __('Min').$series_suffix_str . ' (' . format_for_graph($min_value) . ') ' . $unit;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
$legend['sum'] = __('Avg') . ' (' . $avg_value . ') ' . $unit;
|
$legend['sum'.$series_suffix] = __('Avg').$series_suffix_str . ' (' . $avg_value . ') ' . $unit;
|
||||||
if ($baseline) {
|
if ($baseline) {
|
||||||
$legend['baseline'] = __('Baseline');
|
$legend['baseline'.$series_suffix] = __('Baseline');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
||||||
|
$width, $height , $title = '', $unit_name = null,
|
||||||
|
$show_alerts = false, $avg_only = 0, $pure = false,
|
||||||
|
$date = 0, $unit = '', $baseline = 0, $return_data = 0,
|
||||||
|
$show_title = true, $only_image = false, $homeurl = '', $ttl = 1,
|
||||||
|
$projection = false, $adapt_key = '', $compare = false) {
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
global $graphic_type;
|
||||||
|
|
||||||
|
$flash_chart = $config['flash_charts'];
|
||||||
|
|
||||||
|
enterprise_include_once("include/functions_reporting.php");
|
||||||
|
|
||||||
|
global $chart;
|
||||||
|
global $color;
|
||||||
|
global $legend;
|
||||||
|
global $long_index;
|
||||||
|
global $series_type;
|
||||||
|
global $chart_extra_data;
|
||||||
|
global $warning_min;
|
||||||
|
global $critical_min;
|
||||||
|
|
||||||
|
if($compare) {
|
||||||
|
$series_suffix = '2';
|
||||||
|
$series_suffix_str = ' ('.__('Previous').')';
|
||||||
|
// Build the data of the previous period
|
||||||
|
grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
||||||
|
$width, $height , $title, $unit_name,
|
||||||
|
$show_alerts, $avg_only, $date-$period, $unit, $baseline, $return_data,
|
||||||
|
$show_title, $projection, $adapt_key, $compare,
|
||||||
|
$series_suffix, $series_suffix_str);
|
||||||
|
|
||||||
|
// Store the chart calculated deleting index, because will be over the current period
|
||||||
|
$chart_prev = array_values($chart);
|
||||||
|
$legend_prev = $legend;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build the data of the current period
|
||||||
|
$data_returned = grafico_modulo_sparse_data ($agent_module_id, $period, $show_events,
|
||||||
|
$width, $height , $title, $unit_name,
|
||||||
|
$show_alerts, $avg_only, $date, $unit, $baseline,
|
||||||
|
$return_data, $show_title, $projection, $adapt_key, $compare);
|
||||||
|
|
||||||
|
if ($return_data) {
|
||||||
|
return $data_returned;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($compare) {
|
||||||
|
$i = 0;
|
||||||
|
foreach($chart as $k=>$v) {
|
||||||
|
$chart[$k] = array_merge($v,$chart_prev[$i]);
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$legend = array_merge($legend, $legend_prev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($only_image) {
|
if ($only_image) {
|
||||||
@ -392,9 +478,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||||||
// 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, "images/image_problem.opaque.png", "", $unit, $homeurl,
|
$long_index, "images/image_problem.opaque.png", "", $unit, $homeurl,
|
||||||
$water_mark,
|
$water_mark, $config['fontpath'], $config['font_size'], $unit, $ttl,
|
||||||
$config['fontpath'], $config['font_size'], $unit, $ttl, $series_type,
|
$series_type, $chart_extra_data, $warning_min, $critical_min, $adapt_key);
|
||||||
$chart_extra_data, $warning_min, $critical_min, $adapt_key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function graph_get_formatted_date($timestamp, $format1, $format2) {
|
function graph_get_formatted_date($timestamp, $format1, $format2) {
|
||||||
|
@ -198,6 +198,7 @@ $label = base64_decode(get_parameter('label', ''));
|
|||||||
$zoom = get_parameter ("zoom", 1);
|
$zoom = get_parameter ("zoom", 1);
|
||||||
$baseline = get_parameter ("baseline", 0);
|
$baseline = get_parameter ("baseline", 0);
|
||||||
$show_events_graph = get_parameter ("show_events_graph", 0);
|
$show_events_graph = get_parameter ("show_events_graph", 0);
|
||||||
|
$time_compare = get_parameter ("time_compare", 0);
|
||||||
|
|
||||||
if ($zoom > 1) {
|
if ($zoom > 1) {
|
||||||
$height = $height * ($zoom / 2.1);
|
$height = $height * ($zoom / 2.1);
|
||||||
@ -237,7 +238,7 @@ $label = base64_decode(get_parameter('label', ''));
|
|||||||
case 'sparse':
|
case 'sparse':
|
||||||
echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height,
|
echo grafico_modulo_sparse ($id, $period, $draw_events, $width, $height,
|
||||||
$label, null, $draw_alerts, $avg_only, false, $date, '', $baseline,
|
$label, null, $draw_alerts, $avg_only, false, $date, '', $baseline,
|
||||||
0, true, false, $urlImage, 1, false, 'adapter_'.$graph_type);
|
0, true, false, $urlImage, 1, false, 'adapter_'.$graph_type, $time_compare);
|
||||||
echo '<br><br><br>';
|
echo '<br><br><br>';
|
||||||
if ($show_events_graph)
|
if ($show_events_graph)
|
||||||
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type);
|
echo graphic_module_events($id, $width, $height, $period, $config['homeurl'] . '/', $zoom, 'adapted_'.$graph_type);
|
||||||
@ -379,6 +380,23 @@ $label = base64_decode(get_parameter('label', ''));
|
|||||||
?>
|
?>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<?php
|
||||||
|
switch ($graph_type) {
|
||||||
|
case 'sparse':
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td><?php echo __('Time compare');?></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
html_print_checkbox ("time_compare",
|
||||||
|
1, (bool) $time_compare);
|
||||||
|
?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td style="text-align: right">
|
<td style="text-align: right">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user