2009-04-06 Evi Vanoost <vanooste@rcbi.rochester.edu>

* reporting/fgraph.php: Simplified agent access to reduce looping
	
	* reporting/pChart/pChart.class: Found problem where the graph was
	looping with certain data when the Scale1 was exactly 1

git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1599 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
guruevi 2009-04-06 15:33:08 +00:00
parent 2e566a1738
commit e615a6be89
3 changed files with 101 additions and 119 deletions

View File

@ -1,3 +1,10 @@
2009-04-06 Evi Vanoost <vanooste@rcbi.rochester.edu>
* reporting/fgraph.php: Simplified agent access to reduce looping
* reporting/pChart/pChart.class: Found problem where the graph was
looping with certain data when the Scale1 was exactly 1
2009-04-06 Sancho Lerena <slerena@artica.es>
* godmode/setup/setup.php

View File

@ -430,10 +430,7 @@ function graphic_agentmodules ($id_agent, $width, $height) {
function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
global $config;
/* BROKEN: Need to fix, it gets 100% CPU of Apache !!!*/
$data = array();
/*
$resolution = $config["graph_res"] * ($period * 2 / $width); // Number of "slices" we want in graph
@ -443,48 +440,26 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
$periodtime = floor ($period / $interval);
$time = array ();
$data = array ();
for ($i = 0; $i < $interval; $i++) {
$time[$i]['timestamp_bottom'] = $datelimit + ($periodtime * $i);
$time[$i]['timestamp_top'] = $datelimit + ($periodtime * ($i + 1));
$data[$time[$i]['timestamp_bottom']] = 0;
$bottom = $datelimit + ($periodtime * $i);
$top = $datelimit + ($periodtime * ($i + 1));
$data[$bottom] = (int) get_db_sql ("SELECT COUNT(*) FROM tagent_access WHERE
id_agent = ".$id_agent." AND
utimestamp > ".$bottom." AND
utimestamp < ".$top);
}
$result = get_db_all_rows_filter ('tagent_access',
array ('id_agent' => $id_agent,
"utimestamp > $datelimit",
"utimestamp < $date"),
array ('utimestamp'));
if ($result === false)
$result = array ();
// SEEMS that problem is below
// it get's 100% cpu on apache and problem is localed here, I don't exactly
// why or what is happening here, but i'm sure that the problem is here.
$max_value = 0;
foreach ($result as $access) {
$utimestamp = $access['utimestamp'];
for ($i = 0; $i < $interval; $i++) {
if ($utimestamp <= $time[$i]['timestamp_top'] && $utimestamp >= $time[$i]['timestamp_bottom']) {
$data[$time[$i]['timestamp_bottom']]++;
$max_value = max ($max_value, $data[$time[$i]['timestamp_bottom']]);
}
}
}
*/
$engine = get_graph_engine ($period);
$engine->width = $width;
$engine->height = $height;
$engine->data = &$data;
$engine->max_value = $max_value;
$engine->data = $data;
$engine->max_value = max ($data);
$engine->show_title = false;
$engine->fontpath = $config['fontpath'];
$engine->xaxis_interval = floor ($width / 72);
$engine->yaxis_interval = $max_value;
$engine->yaxis_interval = max ($data);
$engine->xaxis_format = 'date';
$engine->watermark = false;
$engine->show_grid = false;

View File

@ -693,8 +693,8 @@
$Scale2 = ( $this->VMax - $this->VMin ) / $Factor / 2;
$Scale4 = ( $this->VMax - $this->VMin ) / $Factor / 4;
if ( $Scale1 > 1 && $Scale1 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale1); $Scale = 1;}
if ( $Scale2 > 1 && $Scale2 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale2); $Scale = 2;}
if ( $Scale1 >= 1 && $Scale1 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale1); $Scale = 1;}
if ( $Scale2 >= 1 && $Scale2 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale2); $Scale = 2;}
if (!$ScaleOk)
{
if ( $Scale2 > 1 ) { $Factor = $Factor * 10; }