diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-07-22 15:12:15 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-07-22 15:12:15 +0000 |
| commit | af05d3f623c44cd6fcc90c5804a5d9cd9e7528b4 (patch) | |
| tree | 173e3edad3be288a94f2b240dd4149df7ad1430f /frontends/php | |
| parent | 793d78321f5cf73bb79ad8b65ba2bda41fd7a91f (diff) | |
| download | zabbix-af05d3f623c44cd6fcc90c5804a5d9cd9e7528b4.tar.gz zabbix-af05d3f623c44cd6fcc90c5804a5d9cd9e7528b4.tar.xz zabbix-af05d3f623c44cd6fcc90c5804a5d9cd9e7528b4.zip | |
Minor fixes
git-svn-id: svn://svn.zabbix.com/trunk@141 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/trend.html | 150 |
1 files changed, 65 insertions, 85 deletions
diff --git a/frontends/php/trend.html b/frontends/php/trend.html index 8c9912a0..f1a4c0d1 100644 --- a/frontends/php/trend.html +++ b/frontends/php/trend.html @@ -6,147 +6,127 @@ # itemid # type + if(!isset($period)) + { + $period=0; + } + + if(!isset($from)) + { + $from=0; + } + $sizeX=900; $sizeY=200; $shiftX=10; - $shiftYup=10; - $shiftYdown=25; + $shiftY=10; $nodata=1; - Header( "Content-type: text/html"); -// Header( "Content-type: image/png"); + +// Header( "Content-type: text/html"); + Header( "Content-type: image/png"); Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT"); - $im = imagecreate($sizeX+$shiftX+61,$sizeY+$shiftYup+$shiftYdown+10); + $im = imagecreate($sizeX+$shiftX+61,$sizeY+2*$shiftY+10); $red=ImageColorAllocate($im,255,0,0); - $darkred=ImageColorAllocate($im,150,0,0); $green=ImageColorAllocate($im,0,255,0); $darkgreen=ImageColorAllocate($im,0,150,0); $blue=ImageColorAllocate($im,0,0,255); - $darkblue=ImageColorAllocate($im,0,0,150); $yellow=ImageColorAllocate($im,255,255,0); $cyan=ImageColorAllocate($im,0,255,255); $black=ImageColorAllocate($im,0,0,0); - $white=ImageColorAllocate($im,255,255,255); - $gray=ImageColorAllocate($im,150,150,150); - - $colors=array(); - - $colors["Green"]=$green; - $colors["Dark Green"]=$darkgreen; - $colors["Yellow"]=$yellow; - $colors["Blue"]=$blue; - $colors["Dark Blue"]=$blue; - $colors["White"]=$white; - $colors["Cyan"]=$cyan; - $colors["Red"]=$red; - $colors["Dark Red"]=$darkred; $x=imagesx($im); $y=imagesy($im); - ImageFilledRectangle($im,0,0,$sizeX+$shiftX+61,$sizeY+$shiftYup+$shiftYdown+10,$black); + ImageFilledRectangle($im,0,0,$sizeX+$shiftX+61,$sizeY+2*$shiftY+10,$black); for($i=0;$i<=$sizeY;$i+=50) { - ImageDashedLine($im,$shiftX,$i+$shiftYup,$sizeX+$shiftX,$i+$shiftYup,$darkgreen); + ImageDashedLine($im,$shiftX,$i+$shiftY,$sizeX+$shiftX,$i+$shiftY,$darkgreen); } for($i=0;$i<=$sizeX;$i+=50) { - ImageDashedLine($im,$i+$shiftX,$shiftYup,$i+$shiftX,$sizeY+$shiftYup,$darkgreen); + ImageDashedLine($im,$i+$shiftX,$shiftY,$i+$shiftX,$sizeY+$shiftY,$darkgreen); } - $from_time = time(NULL)-$period-3600*$from; - $to_time = time(NULL)-3600*$from; - - $result2=DBselect("select gi.itemid,i.description,gi.color from graphs_items gi,items i where gi.itemid=i.itemid and gi.graphid=$graphid order by gi.gitemid"); - - $len=array(); - $x=array(); - $y=array(); - $desc=array(); - $color=array(); + $now = time(NULL); + $count=array(); + $min=array(); + $max=array(); + $avg=array(); + for($i=0;$i<800;$i++) + { + $result=DBselect("select count(value),min(value),max(value),avg(value) from history where itemid=$itemid and clock>$now-800*61 and clock<$now-800*60"); + $count=DBget_field($result,0,0); + $min=DBget_field($result,0,1); + $max=DBget_field($result,0,2); + $avg=DBget_field($result,0,3); + } + $len=0; $maxX=-1000000000; $maxY=-1000000000; $minX=1000000000; $minY=1000000000; - - for($item=0;$item<DBnum_rows($result2);$item++) + $x=array(); + $y=array(); + $avg=-99999999; + for($i=0;$i<DBnum_rows($result);$i++) { - $itemid=DBget_field($result2,$item,0); - $desc[$item]=DBget_field($result2,$item,1); - $color[$item]=DBget_field($result2,$item,2); - - $result=DBselect("select clock,value from history where itemid=$itemid and clock>$from_time and clock<$to_time order by clock"); - $len[$item]=0; - $x[$item]=array(); - $y[$item]=array(); - for($i=0;$i<DBnum_rows($result);$i++) - { - $nodata=0; - $x[$item][$len[$item]]=DBget_field($result,$i,0); - $y[$item][$len[$item]]=DBget_field($result,$i,1);; - // echo $row[0]," - ",$y[$len],"<Br>"; - if($x[$item][$len[$item]]>$maxX) { $maxX=$x[$item][$len[$item]]; } - if($x[$item][$len[$item]]<$minX) { $minX=$x[$item][$len[$item]]; } - if($y[$item][$len[$item]]>$maxY) { $maxY=$y[$item][$len[$item]]; } - if($y[$item][$len[$item]]<$minY) { $minY=$y[$item][$len[$item]]; } - $len[$item]++; - } + $nodata=0; + $x[$len]=DBget_field($result,$i,0); + $y[$len]=DBget_field($result,$i,1); +// echo $row[0]," - ",$y[$len],"<Br>"; + if($x[$len]>$maxX) { $maxX=$x[$len]; } + if($x[$len]<$minX) { $minX=$x[$len]; } + if($y[$len]>$maxY) { $maxY=$y[$len]; } + if($y[$len]<$minY) { $minY=$y[$len]; } + $len++; } - // echo "MIN/MAX:",$minX," - ",$maxX," - ",$minY," - ",$maxY,"<Br>"; -// $result2=DBselect("select itemid from graphs_items where graphid=$graphid"); - for($item=0;$item<DBnum_rows($result2);$item++) + if(($minX!=$maxX)&&($minY!=$maxY)) { - if(($minX!=$maxX)&&($minY!=$maxY)) - { - for($i=0;$i<$len[$item]-1;$i++) - { - $x1=$sizeX*($x[$item][$i]-$minX)/($maxX-$minX); - $y1=$sizeY*($y[$item][$i]-$minY)/($maxY-$minY); - $x2=$sizeX*($x[$item][$i+1]-$minX)/($maxX-$minX); - $y2=$sizeY*($y[$item][$i+1]-$minY)/($maxY-$minY); - - $y1=$sizeY-$y1; - $y2=$sizeY-$y2; - - // echo $x1," - ",$x2," - ",$y1," - ",$y2,"<Br>"; - ImageLine($im,$x1+$shiftX,$y1+$shiftYup,$x2+$shiftX,$y2+$shiftYup,$colors[$color[$item]]); - } - } - else + for($i=0;$i<$len-1;$i++) { - ImageLine($im,$shiftX,$shiftYup+$sizeY/2,$sizeX+$shiftX,$shiftYup+$sizeY/2,$colors[$color[$item]]); + $x1=$sizeX*($x[$i]-$minX)/($maxX-$minX); + $y1=$sizeY*($y[$i]-$minY)/($maxY-$minY); + $x2=$sizeX*($x[$i+1]-$minX)/($maxX-$minX); + $y2=$sizeY*($y[$i+1]-$minY)/($maxY-$minY); + + $y1=$sizeY-$y1; + $y2=$sizeY-$y2; + +// echo $x1," - ",$x2," - ",$y1," - ",$y2,"<Br>"; + ImageLine($im,$x1+$shiftX,$y1+$shiftY,$x2+$shiftX,$y2+$shiftY,$green); } - ImageFilledRectangle($im,$shiftX+150*$item,$sizeY+$shiftYup+19,$shiftX+150*$item+5,$sizeY+$shiftYup+15+9,$colors[$color[$item]]); - ImageString($im, 2,$shiftX+150*$item+9,$sizeY+$shiftYup+15, $desc[$item], $gray); + } + else + { + ImageLine($im,$shiftX,$shiftY+$sizeY/2,$sizeX+$shiftX,$shiftY+$sizeY/2,$green); } if($nodata == 0) { for($i=0;$i<=$sizeY;$i+=50) { - ImageString($im, 1, $sizeX+5+$shiftX, $sizeY-$i-4+$shiftYup, $i*($maxY-$minY)/$sizeY+$minY , $red); + ImageString($im, 1, $sizeX+5+$shiftX, $sizeY-$i-4+$shiftY, $i*($maxY-$minY)/$sizeY+$minY , $red); } // date("dS of F Y h:i:s A",DBget_field($result,0,0)); - ImageString($im, 1,10, $sizeY+$shiftYup+5, date("dS of F Y h:i:s A",$minX) , $red); - ImageString($im, 1,$sizeX+$shiftX-168,$sizeY+$shiftYup+5, date("dS of F Y h:i:s A",$maxX) , $red); + ImageString($im, 1,10, $sizeY+$shiftY+5, date("dS of F Y h:i:s A",$minX) , $red); + ImageString($im, 1,$sizeX+$shiftX-168,$sizeY+$shiftY+5, date("dS of F Y h:i:s A",$maxX) , $red); } else { - ImageString($im, 2,$sizeX/2 -50, $sizeY+$shiftYup+3, "NO DATA FOR THIS PERIOD" , $red); + ImageString($im, 2,$sizeX/2 -50, $sizeY+$shiftY+3, "NO DATA FOR THIS PERIOD" , $red); } - ImageString($im,0,$shiftX+$sizeX-85,$sizeY+$shiftYup+25, "http://zabbix.sourceforge.net", $gray); - ImagePng($im); ImageDestroy($im); ?> |
