mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-31 01:35:36 +02:00
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:
parent
3216f2fffc
commit
edac0d409e
@ -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>
|
2010-08-02 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
* include/functions_filemanager.php: cleaned source code, changed the show
|
* include/functions_filemanager.php: cleaned source code, changed the show
|
||||||
to buttons of actions (create file, upload...) to out the list of files. And
|
to buttons of actions (create file, upload...) to out the list of files. And
|
||||||
|
@ -1367,13 +1367,9 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||||||
$chart = array();
|
$chart = array();
|
||||||
if ($data[0]['utimestamp'] == $datelimit) {
|
if ($data[0]['utimestamp'] == $datelimit) {
|
||||||
$previous_data = $data[0]['datos'];
|
$previous_data = $data[0]['datos'];
|
||||||
$min_value = $data[0]['datos'];
|
|
||||||
$max_value = $data[0]['datos'];
|
|
||||||
$j++;
|
$j++;
|
||||||
} else {
|
} else {
|
||||||
$previous_data = 0;
|
$previous_data = 0;
|
||||||
$min_value = 0;
|
|
||||||
$max_value = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate chart data
|
// Calculate chart data
|
||||||
@ -1406,16 +1402,7 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||||||
|
|
||||||
// Data in the interval
|
// Data in the interval
|
||||||
if ($count > 0) {
|
if ($count > 0) {
|
||||||
|
|
||||||
// Avg
|
|
||||||
$total /= $count;
|
$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
|
// 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;
|
$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
|
// Fix event and alert scale
|
||||||
$event_max = $max_value * 1.25;
|
$event_max = $max_value * 1.25;
|
||||||
foreach ($chart as $timestamp => $chart_data) {
|
foreach ($chart as $timestamp => $chart_data) {
|
||||||
@ -1492,7 +1484,8 @@ function grafico_modulo_sparse ($agent_module_id, $period, $show_events,
|
|||||||
|
|
||||||
// Flash chart
|
// Flash chart
|
||||||
if (! $graphic_type) {
|
if (! $graphic_type) {
|
||||||
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts);
|
$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);
|
$engine = get_graph_engine ($period);
|
||||||
@ -1609,11 +1602,9 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||||||
$chart = array();
|
$chart = array();
|
||||||
if ($data[0]['utimestamp'] == $datelimit) {
|
if ($data[0]['utimestamp'] == $datelimit) {
|
||||||
$previous_data = $data[0]['datos'];
|
$previous_data = $data[0]['datos'];
|
||||||
$max_value = $data[0]['datos'];
|
|
||||||
$j++;
|
$j++;
|
||||||
} else {
|
} else {
|
||||||
$previous_data = 0;
|
$previous_data = 0;
|
||||||
$max_value = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate chart data
|
// Calculate chart data
|
||||||
@ -1641,11 +1632,6 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||||||
$total /= $count;
|
$total /= $count;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max
|
|
||||||
if ($total > $max_value) {
|
|
||||||
$max_value = $total;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read events and alerts that fall in the current interval
|
// Read events and alerts that fall in the current interval
|
||||||
$event_value = 0;
|
$event_value = 0;
|
||||||
$alert_value = 0;
|
$alert_value = 0;
|
||||||
@ -1697,6 +1683,11 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||||||
$chart[$timestamp]['alert'] = $alert_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
|
// Fix event and alert scale
|
||||||
$event_max = $max_value * 1.25;
|
$event_max = $max_value * 1.25;
|
||||||
foreach ($chart as $timestamp => $chart_data) {
|
foreach ($chart as $timestamp => $chart_data) {
|
||||||
@ -1732,7 +1723,8 @@ function grafico_modulo_boolean ($agent_module_id, $period, $show_events,
|
|||||||
|
|
||||||
// Flash chart
|
// Flash chart
|
||||||
if (! $graphic_type) {
|
if (! $graphic_type) {
|
||||||
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts);
|
$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 ();
|
$chart_data = array ();
|
||||||
@ -1869,11 +1861,9 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
|||||||
$chart = array();
|
$chart = array();
|
||||||
if ($data[0]['utimestamp'] == $datelimit) {
|
if ($data[0]['utimestamp'] == $datelimit) {
|
||||||
$previous_data = 1;
|
$previous_data = 1;
|
||||||
$max_value = 1;
|
|
||||||
$j++;
|
$j++;
|
||||||
} else {
|
} else {
|
||||||
$previous_data = 0;
|
$previous_data = 0;
|
||||||
$max_value = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate chart data
|
// Calculate chart data
|
||||||
@ -1887,11 +1877,6 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
|||||||
$j++;
|
$j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Max
|
|
||||||
if ($count > $max_value) {
|
|
||||||
$max_value = $count;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Read events and alerts that fall in the current interval
|
// Read events and alerts that fall in the current interval
|
||||||
$event_value = 0;
|
$event_value = 0;
|
||||||
$alert_value = 0;
|
$alert_value = 0;
|
||||||
@ -1923,6 +1908,11 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
|||||||
$chart[$timestamp]['alert'] = $alert_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
|
// Fix event and alert scale
|
||||||
$event_max = $max_value * 1.25;
|
$event_max = $max_value * 1.25;
|
||||||
foreach ($chart as $timestamp => $chart_data) {
|
foreach ($chart as $timestamp => $chart_data) {
|
||||||
@ -1958,7 +1948,8 @@ function grafico_modulo_string ($agent_module_id, $period, $show_events,
|
|||||||
|
|
||||||
// Flash chart
|
// Flash chart
|
||||||
if (! $graphic_type) {
|
if (! $graphic_type) {
|
||||||
return fs_module_chart ($chart, $width, $height, $avg_only, $resolution / 10, $time_format, $show_events, $show_alerts);
|
$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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ function fs_2d_area_chart ($data, $width, $height, $step = 1, $params = '') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Returns a Pandora FMS module chart
|
// 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;
|
global $config;
|
||||||
|
|
||||||
// Generate the XML
|
// Generate the XML
|
||||||
@ -139,6 +139,10 @@ function fs_module_chart ($data, $width, $height, $avg_only = 1, $step = 10, $ti
|
|||||||
$num_vlines = 0;
|
$num_vlines = 0;
|
||||||
$count = 0;
|
$count = 0;
|
||||||
|
|
||||||
|
if ($caption != '') {
|
||||||
|
$chart->setChartParam("caption", $caption);
|
||||||
|
}
|
||||||
|
|
||||||
// Create categories
|
// Create categories
|
||||||
foreach ($data as $value) {
|
foreach ($data as $value) {
|
||||||
if ($count++ % $step == 0) {
|
if ($count++ % $step == 0) {
|
||||||
|
@ -153,7 +153,6 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
|
|||||||
|
|
||||||
// Uncompressed module data
|
// Uncompressed module data
|
||||||
if ($uncompressed_module) {
|
if ($uncompressed_module) {
|
||||||
$min_necessary = 1;
|
|
||||||
|
|
||||||
// Compressed module data
|
// Compressed module data
|
||||||
} else {
|
} else {
|
||||||
@ -176,22 +175,15 @@ function get_agentmodule_data_max ($id_agent_module, $period, $date = 0) {
|
|||||||
$next_data['utimestamp'] = $date;
|
$next_data['utimestamp'] = $date;
|
||||||
array_push ($interval_data, $next_data);
|
array_push ($interval_data, $next_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$min_necessary = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (count ($interval_data) < $min_necessary) {
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set initial conditions
|
// Set initial conditions
|
||||||
|
if ($uncompressed_module || $interval_data[0]['utimestamp'] == $datelimit) {
|
||||||
|
$max = $interval_data[0]['datos'];
|
||||||
|
} else {
|
||||||
$max = 0;
|
$max = 0;
|
||||||
if (! $uncompressed_module) {
|
|
||||||
$previous_data = array_shift ($interval_data);
|
|
||||||
if ($previous_data['utimestamp'] == $datelimit) {
|
|
||||||
$max = $previous_data['datos'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($interval_data as $data) {
|
foreach ($interval_data as $data) {
|
||||||
if ($data['datos'] > $max) {
|
if ($data['datos'] > $max) {
|
||||||
$max = $data['datos'];
|
$max = $data['datos'];
|
||||||
@ -255,22 +247,19 @@ function get_agentmodule_data_min ($id_agent_module, $period, $date = 0) {
|
|||||||
$next_data['utimestamp'] = $date;
|
$next_data['utimestamp'] = $date;
|
||||||
array_push ($interval_data, $next_data);
|
array_push ($interval_data, $next_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
$min_necessary = 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count ($interval_data) < $min_necessary) {
|
if (count ($interval_data) < 1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set initial conditions
|
// Set initial conditions
|
||||||
|
if ($uncompressed_module || $interval_data[0]['utimestamp'] == $datelimit) {
|
||||||
|
$min = $interval_data[0]['datos'];
|
||||||
|
} else {
|
||||||
$min = 0;
|
$min = 0;
|
||||||
if (! $uncompressed_module) {
|
|
||||||
$previous_data = array_shift ($interval_data);
|
|
||||||
if ($previous_data['utimestamp'] == $datelimit) {
|
|
||||||
$min = $previous_data['datos'];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($interval_data as $data) {
|
foreach ($interval_data as $data) {
|
||||||
if ($data['datos'] < $min) {
|
if ($data['datos'] < $min) {
|
||||||
$min = $data['datos'];
|
$min = $data['datos'];
|
||||||
|
@ -166,14 +166,6 @@ else {
|
|||||||
print_image ($image, false, array ("border" => 0));
|
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.
|
//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 '<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">';
|
echo '<form method="get" action="stat_win.php">';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user