diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-07-22 09:19:43 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2001-07-22 09:19:43 +0000 |
| commit | fe419ea13516eb6c560bda8d2601f600efdfd888 (patch) | |
| tree | 53b8bc1026f873b1a4f73dcd3c4dfb2de184228f /frontends/php | |
| parent | a35c3ce4c7f950bb95908151664651d809cf611e (diff) | |
| download | zabbix-fe419ea13516eb6c560bda8d2601f600efdfd888.tar.gz zabbix-fe419ea13516eb6c560bda8d2601f600efdfd888.tar.xz zabbix-fe419ea13516eb6c560bda8d2601f600efdfd888.zip | |
Add basci support for trends
git-svn-id: svn://svn.zabbix.com/trunk@137 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/latest.html | 3 | ||||
| -rw-r--r-- | frontends/php/trend.html | 152 | ||||
| -rw-r--r-- | frontends/php/trends.html | 84 |
3 files changed, 239 insertions, 0 deletions
diff --git a/frontends/php/latest.html b/frontends/php/latest.html index 49a1889b..8f6e2392 100644 --- a/frontends/php/latest.html +++ b/frontends/php/latest.html @@ -82,6 +82,8 @@ cr(); echo "<TD WIDTH=\"10%\" NOSAVE><center><B>History</B></center></TD>"; cr(); + echo "<TD WIDTH=\"10%\" NOSAVE><center><B>Trends</B></center></TD>"; + cr(); echo "</TR>"; cr(); } @@ -146,6 +148,7 @@ echo "<td><center>-</center></td>"; } echo "<td><center><a href=\"history.html?action=showhistory&itemid=$itemid\">Show</a></center></td>"; + echo "<td><center><a href=\"trends.html?itemid=$itemid\">Show</a></center></td>"; echo "</tr>"; } echo "</table>"; diff --git a/frontends/php/trend.html b/frontends/php/trend.html new file mode 100644 index 00000000..8c9912a0 --- /dev/null +++ b/frontends/php/trend.html @@ -0,0 +1,152 @@ +<? + include "include/config.inc"; + +# PARAMETERS: + +# itemid +# type + + $sizeX=900; + $sizeY=200; + + $shiftX=10; + $shiftYup=10; + $shiftYdown=25; + + $nodata=1; + + 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); + + $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); + + for($i=0;$i<=$sizeY;$i+=50) + { + ImageDashedLine($im,$shiftX,$i+$shiftYup,$sizeX+$shiftX,$i+$shiftYup,$darkgreen); + } + for($i=0;$i<=$sizeX;$i+=50) + { + ImageDashedLine($im,$i+$shiftX,$shiftYup,$i+$shiftX,$sizeY+$shiftYup,$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(); + + $maxX=-1000000000; + $maxY=-1000000000; + $minX=1000000000; + $minY=1000000000; + + for($item=0;$item<DBnum_rows($result2);$item++) + { + $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]++; + } + } + +// 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)) + { + 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 + { + ImageLine($im,$shiftX,$shiftYup+$sizeY/2,$sizeX+$shiftX,$shiftYup+$sizeY/2,$colors[$color[$item]]); + } + 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); + } + + 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); + } + +// 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); + } + else + { + ImageString($im, 2,$sizeX/2 -50, $sizeY+$shiftYup+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); +?> diff --git a/frontends/php/trends.html b/frontends/php/trends.html new file mode 100644 index 00000000..5ff77eec --- /dev/null +++ b/frontends/php/trends.html @@ -0,0 +1,84 @@ +<? + include "include/config.inc"; + $page["title"] = "Latest values"; + $page["file"] = "latest.html"; + show_header($page["title"],0,0); +?> + +<? + show_table_header_begin(); + $result=DBselect("select description from items where itemid=$itemid"); + echo "TRENDS [",DBget_field($result,0,0),"]"; + + show_table_v_delimiter(); + + echo "<font size=2>"; + + if(isset($type)&&$type=="yearly") + { + echo "<b>[<a href='trends.html?itemid=$itemid&type=yearly'>yearly</a>]</b> "; + } + else + { + echo "<a href='trends.html?itemid=$itemid&type=yearly'>yearly</a> "; + } + if(isset($type)&&$type=="monthly") + { + echo "<b>[<a href='trends.html?itemid=$itemid&type=monthly'>monthly</a>]</b> "; + } + else + { + echo "<a href='trends.html?itemid=$itemid&type=monthly'>monthly</a> "; + } + if(isset($type)&&$type=="daily") + { + echo "<b>[<a href='trends.html?itemid=$itemid&type=daily'>daily</a>]</b> "; + } + else + { + echo "<a href='trends.html?itemid=$itemid&type=daily'>daily</a> "; + } + if(isset($type)&&$type=="hourly") + { + echo "<b>[<a href='trends.html?itemid=$itemid&type=hourly'>hourly</a>]</b> "; + } + else + { + echo "<a href='trends.html?itemid=$itemid&type=hourly'>hourly</a> "; + } + + echo "</font>"; + show_table_header_end(); + echo "<br>"; +?> + +<? + if(isset($itemid)&&isset($type)) + { + show_table_header(strtoupper($type)); + } + else + { + show_table_header("Select type of trend"); + } + echo "<TABLE BORDER=0 COLS=4 WIDTH=\"100%\" BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>"; + echo "<TR BGCOLOR=#EEEEEE>"; + echo "<TR BGCOLOR=#DDDDDD>"; + echo "<TD ALIGN=CENTER>"; + if(isset($itemid)&&isset($type)) + { + echo "<IMG SRC=\"trend.html?itemid=$itemid&type=$type\">"; + } + else + { + echo "..."; + } + echo "</TD>"; + echo "</TR>"; + echo "</TABLE>"; + +?> + +<? + show_footer(); +?> |
