mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
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:
parent
2e566a1738
commit
e615a6be89
@ -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>
|
2009-04-06 Sancho Lerena <slerena@artica.es>
|
||||||
|
|
||||||
* godmode/setup/setup.php
|
* godmode/setup/setup.php
|
||||||
|
@ -430,11 +430,8 @@ function graphic_agentmodules ($id_agent, $width, $height) {
|
|||||||
function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
|
function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
/* BROKEN: Need to fix, it gets 100% CPU of Apache !!!*/
|
|
||||||
|
|
||||||
$data = array();
|
$data = array();
|
||||||
/*
|
|
||||||
|
|
||||||
$resolution = $config["graph_res"] * ($period * 2 / $width); // Number of "slices" we want in graph
|
$resolution = $config["graph_res"] * ($period * 2 / $width); // Number of "slices" we want in graph
|
||||||
|
|
||||||
$interval = (int) ($period / $resolution);
|
$interval = (int) ($period / $resolution);
|
||||||
@ -443,52 +440,30 @@ function graphic_agentaccess ($id_agent, $width, $height, $period = 0) {
|
|||||||
$periodtime = floor ($period / $interval);
|
$periodtime = floor ($period / $interval);
|
||||||
$time = array ();
|
$time = array ();
|
||||||
$data = array ();
|
$data = array ();
|
||||||
|
|
||||||
for ($i = 0; $i < $interval; $i++) {
|
for ($i = 0; $i < $interval; $i++) {
|
||||||
$time[$i]['timestamp_bottom'] = $datelimit + ($periodtime * $i);
|
$bottom = $datelimit + ($periodtime * $i);
|
||||||
$time[$i]['timestamp_top'] = $datelimit + ($periodtime * ($i + 1));
|
$top = $datelimit + ($periodtime * ($i + 1));
|
||||||
$data[$time[$i]['timestamp_bottom']] = 0;
|
$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 = get_graph_engine ($period);
|
||||||
|
|
||||||
$engine->width = $width;
|
$engine->width = $width;
|
||||||
$engine->height = $height;
|
$engine->height = $height;
|
||||||
$engine->data = &$data;
|
$engine->data = $data;
|
||||||
$engine->max_value = $max_value;
|
$engine->max_value = max ($data);
|
||||||
$engine->show_title = false;
|
$engine->show_title = false;
|
||||||
$engine->fontpath = $config['fontpath'];
|
$engine->fontpath = $config['fontpath'];
|
||||||
$engine->xaxis_interval = floor ($width / 72);
|
$engine->xaxis_interval = floor ($width / 72);
|
||||||
$engine->yaxis_interval = $max_value;
|
$engine->yaxis_interval = max ($data);
|
||||||
$engine->xaxis_format = 'date';
|
$engine->xaxis_format = 'date';
|
||||||
$engine->watermark = false;
|
$engine->watermark = false;
|
||||||
$engine->show_grid = false;
|
$engine->show_grid = false;
|
||||||
|
|
||||||
$engine->single_graph ();
|
$engine->single_graph ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Updated for Pandora on 2009-03-12. Changes:
|
Updated for Pandora on 2009-03-12. Changes:
|
||||||
|
|
||||||
- Added drawOverlayBarGraphH()
|
- Added drawOverlayBarGraphH()
|
||||||
- Draw a single rectangle on drawRoundedRectangle() when the radius is 0.
|
- Draw a single rectangle on drawRoundedRectangle() when the radius is 0.
|
||||||
- Typo when calling $ko on ToMetric()
|
- Typo when calling $ko on ToMetric()
|
||||||
|
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
pChart - a PHP class to build charts!
|
pChart - a PHP class to build charts!
|
||||||
Copyright (C) 2008 Jean-Damien POGOLOTTI
|
Copyright (C) 2008 Jean-Damien POGOLOTTI
|
||||||
Version 1.27d last updated on 09/30/08
|
Version 1.27d last updated on 09/30/08
|
||||||
|
|
||||||
http://pchart.sourceforge.net
|
http://pchart.sourceforge.net
|
||||||
|
|
||||||
@ -693,8 +693,8 @@
|
|||||||
$Scale2 = ( $this->VMax - $this->VMin ) / $Factor / 2;
|
$Scale2 = ( $this->VMax - $this->VMin ) / $Factor / 2;
|
||||||
$Scale4 = ( $this->VMax - $this->VMin ) / $Factor / 4;
|
$Scale4 = ( $this->VMax - $this->VMin ) / $Factor / 4;
|
||||||
|
|
||||||
if ( $Scale1 > 1 && $Scale1 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale1); $Scale = 1;}
|
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 ( $Scale2 >= 1 && $Scale2 <= $MaxDivs && !$ScaleOk) { $ScaleOk = TRUE; $Divisions = floor($Scale2); $Scale = 2;}
|
||||||
if (!$ScaleOk)
|
if (!$ScaleOk)
|
||||||
{
|
{
|
||||||
if ( $Scale2 > 1 ) { $Factor = $Factor * 10; }
|
if ( $Scale2 > 1 ) { $Factor = $Factor * 10; }
|
||||||
@ -950,8 +950,8 @@
|
|||||||
$YPos = $YPos - $this->DivisionHeight;
|
$YPos = $YPos - $this->DivisionHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Vertical lines */
|
/* Vertical lines */
|
||||||
if (!$DrawVerticals)
|
if (!$DrawVerticals)
|
||||||
return;
|
return;
|
||||||
if ( $this->GAreaXOffset == 0 )
|
if ( $this->GAreaXOffset == 0 )
|
||||||
{ $XPos = $this->GArea_X1 + $this->DivisionWidth + $this->GAreaXOffset; $ColCount = $this->DataCount-2; }
|
{ $XPos = $this->GArea_X1 + $this->DivisionWidth + $this->GAreaXOffset; $ColCount = $this->DataCount-2; }
|
||||||
@ -1078,70 +1078,70 @@
|
|||||||
$ID++;
|
$ID++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function drawOverlayBarGraphH($Data,$DataDescription,$Alpha=50)
|
function drawOverlayBarGraphH($Data,$DataDescription,$Alpha=50)
|
||||||
{
|
{
|
||||||
/* Validate the Data and DataDescription array */
|
/* Validate the Data and DataDescription array */
|
||||||
$this->validateDataDescription("drawOverlayBarGraphH",$DataDescription);
|
$this->validateDataDescription("drawOverlayBarGraphH",$DataDescription);
|
||||||
$this->validateData("drawOverlayBarGraphH",$Data);
|
$this->validateData("drawOverlayBarGraphH",$Data);
|
||||||
|
|
||||||
$LayerWidth = $this->GArea_X2-$this->GArea_X1;
|
$LayerWidth = $this->GArea_X2-$this->GArea_X1;
|
||||||
$LayerHeight = $this->GArea_Y2-$this->GArea_Y1;
|
$LayerHeight = $this->GArea_Y2-$this->GArea_Y1;
|
||||||
|
|
||||||
$GraphID = 0;
|
$GraphID = 0;
|
||||||
foreach ( $DataDescription["Values"] as $Key2 => $ColName )
|
foreach ( $DataDescription["Values"] as $Key2 => $ColName )
|
||||||
{
|
{
|
||||||
$ID = 0;
|
$ID = 0;
|
||||||
foreach ( $DataDescription["Description"] as $keyI => $ValueI )
|
foreach ( $DataDescription["Description"] as $keyI => $ValueI )
|
||||||
{
|
{
|
||||||
if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++;
|
if ( $keyI == $ColName ) { $ColorID = $ID; }; $ID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->Layers[$GraphID] = imagecreatetruecolor($LayerWidth,$LayerHeight);
|
$this->Layers[$GraphID] = imagecreatetruecolor($LayerWidth,$LayerHeight);
|
||||||
$C_White = imagecolorallocate($this->Layers[$GraphID],255,255,255);
|
$C_White = imagecolorallocate($this->Layers[$GraphID],255,255,255);
|
||||||
$C_Black = imagecolorallocate($this->Layers[$GraphID],0,0,0);
|
$C_Black = imagecolorallocate($this->Layers[$GraphID],0,0,0);
|
||||||
$C_Graph = imagecolorallocate($this->Layers[$GraphID],$this->Palette[$GraphID]["R"],$this->Palette[$GraphID]["G"],$this->Palette[$GraphID]["B"]);
|
$C_Graph = imagecolorallocate($this->Layers[$GraphID],$this->Palette[$GraphID]["R"],$this->Palette[$GraphID]["G"],$this->Palette[$GraphID]["B"]);
|
||||||
imagefilledrectangle($this->Layers[$GraphID],0,0,$LayerWidth,$LayerHeight,$C_White);
|
imagefilledrectangle($this->Layers[$GraphID],0,0,$LayerWidth,$LayerHeight,$C_White);
|
||||||
imagecolortransparent($this->Layers[$GraphID],$C_White);
|
imagecolortransparent($this->Layers[$GraphID],$C_White);
|
||||||
|
|
||||||
$XWidth = $this->DivisionWidth / 4;
|
$XWidth = $this->DivisionWidth / 4;
|
||||||
$XPos = $this->GAreaXOffset;
|
$XPos = $this->GAreaXOffset;
|
||||||
$YZero = $LayerHeight - ((0-$this->VMin) * $this->DivisionRatio);
|
$YZero = $LayerHeight - ((0-$this->VMin) * $this->DivisionRatio);
|
||||||
$XLast = -1; $PointsCount = 2;
|
$XLast = -1; $PointsCount = 2;
|
||||||
$XZero = 0;
|
$XZero = 0;
|
||||||
$YPad = 20; //$LayerHeight / count($Data);
|
$YPad = 20; //$LayerHeight / count($Data);
|
||||||
$YHeight = 8;
|
$YHeight = 8;
|
||||||
$YPos = $YHeight;
|
$YPos = $YHeight;
|
||||||
$Divisi = ($LayerWidth / ($this->VMax - $this->VMin));
|
$Divisi = ($LayerWidth / ($this->VMax - $this->VMin));
|
||||||
foreach ( $Data as $Key => $Values )
|
foreach ( $Data as $Key => $Values )
|
||||||
{
|
{
|
||||||
if ( isset($Data[$Key][$ColName]) )
|
if ( isset($Data[$Key][$ColName]) )
|
||||||
{
|
{
|
||||||
$Value = $Data[$Key][$ColName];
|
$Value = $Data[$Key][$ColName];
|
||||||
$XPos = (($Value-$this->VMin) * $Divisi) ;
|
$XPos = (($Value-$this->VMin) * $Divisi) ;
|
||||||
|
|
||||||
imagefilledrectangle($this->Layers[$GraphID],$XPos,$YPos+$YHeight,$XZero,$YPos-$YHeight,$C_Graph);
|
imagefilledrectangle($this->Layers[$GraphID],$XPos,$YPos+$YHeight,$XZero,$YPos-$YHeight,$C_Graph);
|
||||||
imagettftext($this->Layers[$GraphID],$this->FontSize,0,$XZero+2,$YPos+4,$C_Black,$this->FontName, $Data[$Key][$DataDescription["Position"]]." (".round($Value,2).")");
|
imagettftext($this->Layers[$GraphID],$this->FontSize,0,$XZero+2,$YPos+4,$C_Black,$this->FontName, $Data[$Key][$DataDescription["Position"]]." (".round($Value,2).")");
|
||||||
|
|
||||||
$X1 = floor($XPos - $XWidth + $this->GArea_X1); $Y1 = floor($YPos+$this->GArea_Y1) + .2;
|
$X1 = floor($XPos - $XWidth + $this->GArea_X1); $Y1 = floor($YPos+$this->GArea_Y1) + .2;
|
||||||
$X2 = floor($XPos + $XWidth + $this->GArea_X1);
|
$X2 = floor($XPos + $XWidth + $this->GArea_X1);
|
||||||
if ( $X1 <= $this->GArea_X1 ) { $X1 = $this->GArea_X1 + 1; }
|
if ( $X1 <= $this->GArea_X1 ) { $X1 = $this->GArea_X1 + 1; }
|
||||||
if ( $X2 >= $this->GArea_X2 ) { $X2 = $this->GArea_X2 - 1; }
|
if ( $X2 >= $this->GArea_X2 ) { $X2 = $this->GArea_X2 - 1; }
|
||||||
if ( $this->BuildMap )
|
if ( $this->BuildMap )
|
||||||
$this->addToImageMap($X1,min($Y1,$Y2),$X2,max($Y1,$Y2),$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"oBar");
|
$this->addToImageMap($X1,min($Y1,$Y2),$X2,max($Y1,$Y2),$DataDescription["Description"][$ColName],$Data[$Key][$ColName].$DataDescription["Unit"]["Y"],"oBar");
|
||||||
|
|
||||||
$this->drawLine($X1,$Y1,$X2,$Y1,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);
|
$this->drawLine($X1,$Y1,$X2,$Y1,$this->Palette[$ColorID]["R"],$this->Palette[$ColorID]["G"],$this->Palette[$ColorID]["B"]);
|
||||||
}
|
}
|
||||||
$YPos= $YPos + $YPad;
|
$YPos= $YPos + $YPad;
|
||||||
}
|
}
|
||||||
|
|
||||||
$GraphID++;
|
$GraphID++;
|
||||||
}
|
}
|
||||||
|
|
||||||
for($i=0;$i<=($GraphID-1);$i++)
|
for($i=0;$i<=($GraphID-1);$i++)
|
||||||
{
|
{
|
||||||
imagecopymerge($this->Picture,$this->Layers[$i],$this->GArea_X1,$this->GArea_Y1,0,0,$LayerWidth,$LayerHeight,$Alpha);
|
imagecopymerge($this->Picture,$this->Layers[$i],$this->GArea_X1,$this->GArea_Y1,0,0,$LayerWidth,$LayerHeight,$Alpha);
|
||||||
imagedestroy($this->Layers[$i]);
|
imagedestroy($this->Layers[$i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Draw the graph title */
|
/* Draw the graph title */
|
||||||
function drawTitle($XPos,$YPos,$Value,$R,$G,$B,$XPos2=-1,$YPos2=-1,$Shadow=FALSE)
|
function drawTitle($XPos,$YPos,$Value,$R,$G,$B,$XPos2=-1,$YPos2=-1,$Shadow=FALSE)
|
||||||
@ -2949,9 +2949,9 @@
|
|||||||
{
|
{
|
||||||
if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
|
if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
|
||||||
if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
|
if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
|
||||||
if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
|
if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
|
||||||
|
|
||||||
if ( $Radius == 0 ) { $this->drawRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B); return; }
|
if ( $Radius == 0 ) { $this->drawRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B); return; }
|
||||||
|
|
||||||
$C_Rectangle = $this->AllocateColor($this->Picture,$R,$G,$B);
|
$C_Rectangle = $this->AllocateColor($this->Picture,$R,$G,$B);
|
||||||
|
|
||||||
@ -2990,7 +2990,7 @@
|
|||||||
if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
|
if ( $R < 0 ) { $R = 0; } if ( $R > 255 ) { $R = 255; }
|
||||||
if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
|
if ( $G < 0 ) { $G = 0; } if ( $G > 255 ) { $G = 255; }
|
||||||
if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
|
if ( $B < 0 ) { $B = 0; } if ( $B > 255 ) { $B = 255; }
|
||||||
|
|
||||||
if ( $Radius == 0 ) { $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B); return; }
|
if ( $Radius == 0 ) { $this->drawFilledRectangle($X1,$Y1,$X2,$Y2,$R,$G,$B); return; }
|
||||||
$C_Rectangle = $this->AllocateColor($this->Picture,$R,$G,$B);
|
$C_Rectangle = $this->AllocateColor($this->Picture,$R,$G,$B);
|
||||||
|
|
||||||
@ -3563,6 +3563,6 @@
|
|||||||
{
|
{
|
||||||
echo "[FATAL] ".$Message."\r\n";
|
echo "[FATAL] ".$Message."\r\n";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user