2010-08-02 Ramon Novoa <rnovoa@artica.es>

* include/functions_reporting.php, include/fgraph.php,
          include/functions_fsgraph.php, operation/agentes/stat_win.php: Moved
          min, max and avg information into the chart to make it available to
          reports an custom graphs.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3084 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
ramonn 2010-08-02 12:15:33 +00:00
parent 3216f2fffc
commit edac0d409e
5 changed files with 48 additions and 65 deletions

View File

@ -1,3 +1,10 @@
2010-08-02 Ramon Novoa <rnovoa@artica.es>
* include/functions_reporting.php, include/fgraph.php,
include/functions_fsgraph.php, operation/agentes/stat_win.php: Moved
min, max and avg information into the chart to make it available to
reports an custom graphs.
2010-08-02 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_filemanager.php: cleaned source code, changed the show
to buttons of actions (create file, upload...) to out the list of files. And

View File

@ -1367,13 +1367,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$chart = array();
if ($data[0]['utimestamp'] == $datelimit) {
$previous_data = $data[0]['datos'];
$min_value = $data[0]['datos'];
$max_value = $data[0]['datos'];
$j++;
} else {
$previous_data = 0;
$min_value = 0;
$max_value = 0;
}
// Calculate chart data
@ -1406,16 +1402,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
// Data in the interval
if ($count > 0) {
// Avg
$total /= $count;
// Min and max
if ($interval_max > $max_value) {
$max_value = $interval_max;
} else if ($interval_min < $min_value) {
$min_value = $interval_min;
}
}
// Read events and alerts that fall in the current interval
@ -1457,6 +1444,11 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
$chart[$timestamp]['alert'] = $alert_value;
}
// Get min, max and avg (less efficient but centralized for all modules and reports)
$min_value = round(get_agentmodule_data_min ($agent_module_id, $period, $date), 2);
$max_value = round(get_agentmodule_data_max ($agent_module_id, $period, $date), 2);
$avg_value = round(get_agentmodule_data_average ($agent_module_id, $period, $date), 2);
// Fix event and alert scale
$event_max = $max_value * 1.25;
foreach ($chart as $timestamp => $chart_data) {
@ -1491,8 +1483,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
}
// Flash chart
if (! $graphic_type) {
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts);
if (! $graphic_type) {
$caption = __('Max. Value') . ': ' . $min_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value;
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption);
}
$engine = get_graph_engine ($period);
@ -1609,11 +1602,9 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
$chart = array();
if ($data[0]['utimestamp'] == $datelimit) {
$previous_data = $data[0]['datos'];
$max_value = $data[0]['datos'];
$j++;
} else {
$previous_data = 0;
$max_value = 0;
}
// Calculate chart data
@ -1641,11 +1632,6 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
$total /= $count;
}
// Max
if ($total > $max_value) {
$max_value = $total;
}
// Read events and alerts that fall in the current interval
$event_value = 0;
$alert_value = 0;
@ -1696,7 +1682,12 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
$chart[$timestamp]['event'] = $event_value;
$chart[$timestamp]['alert'] = $alert_value;
}
// Get min, max and avg (less efficient but centralized for all modules and reports)
$min_value = round(get_agentmodule_data_min ($agent_module_id, $period, $date), 2);
$max_value = round(get_agentmodule_data_max ($agent_module_id, $period, $date), 2);
$avg_value = round(get_agentmodule_data_average ($agent_module_id, $period, $date), 2);
// Fix event and alert scale
$event_max = $max_value * 1.25;
foreach ($chart as $timestamp => $chart_data) {
@ -1731,8 +1722,9 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
}
// Flash chart
if (! $graphic_type) {
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts);
if (! $graphic_type) {
$caption = __('Max. Value') . ': ' . $max_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value;
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption);
}
$chart_data = array ();
@ -1869,11 +1861,9 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$chart = array();
if ($data[0]['utimestamp'] == $datelimit) {
$previous_data = 1;
$max_value = 1;
$j++;
} else {
$previous_data = 0;
$max_value = 0;
}
// Calculate chart data
@ -1887,11 +1877,6 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$j++;
}
// Max
if ($count > $max_value) {
$max_value = $count;
}
// Read events and alerts that fall in the current interval
$event_value = 0;
$alert_value = 0;
@ -1923,6 +1908,11 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
$chart[$timestamp]['alert'] = $alert_value;
}
// Get min, max and avg (less efficient but centralized for all modules and reports)
$min_value = round(get_agentmodule_data_min ($agent_module_id, $period, $date), 2);
$max_value = round(get_agentmodule_data_max ($agent_module_id, $period, $date), 2);
$avg_value = round(get_agentmodule_data_average ($agent_module_id, $period, $date), 2);
// Fix event and alert scale
$event_max = $max_value * 1.25;
foreach ($chart as $timestamp => $chart_data) {
@ -1957,8 +1947,9 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
}
// Flash chart
if (! $graphic_type) {
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts);
if (! $graphic_type) {
$caption = __('Max. Value') . ': ' . $min_value . ' ' . __('Avg. Value') . ': ' . $avg_value . ' ' . __('Min. Value') . ': ' . $min_value;
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts, $caption);
}

View File

@ -131,7 +131,7 @@ function fs_2d_area_chart ($data, $width, $height, $step = 1, $params = '') {
}
// Returns a Pandora FMS module chart
function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $time_format = 'G:i', $show_events = 0, $show_alerts = 0) {
function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $time_format = 'G:i', $show_events = 0, $show_alerts = 0, $caption = '') {
global $config;
// Generate the XML
@ -139,6 +139,10 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti
$num_vlines = 0;
$count = 0;
if ($caption != '') {
$chart->setChartParam("caption", $caption);
}
// Create categories
foreach ($data as $value) {
if ($count++ % $step == 0) {

View File

@ -153,7 +153,6 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
// Uncompressed module data
if ($uncompressed_module) {
$min_necessary = 1;
// Compressed module data
} else {
@ -176,22 +175,15 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
$next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data);
}
$min_necessary = 2;
}
if (count ($interval_data) < $min_necessary) {
return -1;
}
// Set initial conditions
$max = 0;
if (! $uncompressed_module) {
$previous_data = array_shift ($interval_data);
if ($previous_data['utimestamp'] == $datelimit) {
$max = $previous_data['datos'];
}
if ($uncompressed_module || $interval_data[0]['utimestamp'] == $datelimit) {
$max = $interval_data[0]['datos'];
} else {
$max = 0;
}
foreach ($interval_data as $data) {
if ($data['datos'] > $max) {
$max = $data['datos'];
@ -255,22 +247,19 @@ function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) {
$next_data['utimestamp'] = $date;
array_push ($interval_data, $next_data);
}
$min_necessary = 2;
}
if (count ($interval_data) < $min_necessary) {
if (count ($interval_data) < 1) {
return -1;
}
// Set initial conditions
$min = 0;
if (! $uncompressed_module) {
$previous_data = array_shift ($interval_data);
if ($previous_data['utimestamp'] == $datelimit) {
$min = $previous_data['datos'];
}
if ($uncompressed_module || $interval_data[0]['utimestamp'] == $datelimit) {
$min = $interval_data[0]['datos'];
} else {
$min = 0;
}
foreach ($interval_data as $data) {
if ($data['datos'] < $min) {
$min = $data['datos'];

View File

@ -166,14 +166,6 @@ else {
print_image ($image, false, array ("border" => 0));
}
if ($graph_type != "log4x") {
echo '<table width="450" cellspacing="1" cellpadding="1" class="databox" style="margin-left: 20px">';
echo '<tr><td><b>'.__('Max. Value').'</b>: '.format_for_graph (get_agentmodule_data_max ($id, $period, $date));
echo '</td><td><b>'.__('Avg. Value').'</b>: '.format_for_graph (get_agentmodule_data_average ($id, $period, $date));
echo '</td><td><b>'.__('Min. Value').'</b>: '.format_for_graph (get_agentmodule_data_min ($id, $period, $date));
echo '</td></tr></table>';
}
//z-index is 1 because 2 made the calendar show under the divmenu.
echo '<div id="divmenu" class="menu" style="z-index:1;"><b>'.__('Pandora FMS Graph configuration menu').'</b><br />'.__('Please, make your changes and apply with the <i>Reload</i> button');
echo '<form method="get" action="stat_win.php">';