diff options
| author | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2003-07-20 18:15:21 +0000 |
|---|---|---|
| committer | hugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2003-07-20 18:15:21 +0000 |
| commit | edb44e0293222987bcbaf6409c021c767c6faeec (patch) | |
| tree | baee5dd84d6b408971e24c1ba72e6ec6bb2411bb /frontends/php | |
| parent | 960f15d24df774d5853ad8e8cbcaf81f0c61d56d (diff) | |
| download | zabbix-edb44e0293222987bcbaf6409c021c767c6faeec.tar.gz zabbix-edb44e0293222987bcbaf6409c021c767c6faeec.tar.xz zabbix-edb44e0293222987bcbaf6409c021c767c6faeec.zip | |
- support for changing of graph items (Alexei)
- menu will not require more than three lines (Alexei)
- fixed dividion by zero in chart2.php (Alexei)
- period and start of interval are preserved in full-screen mode (Alexei)
- added units in graph legends (Alexei)
- table-like legend for user graphs (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@853 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
| -rw-r--r-- | frontends/php/chart.php | 769 | ||||
| -rw-r--r-- | frontends/php/chart2.php | 18 | ||||
| -rw-r--r-- | frontends/php/charts.php | 13 | ||||
| -rw-r--r-- | frontends/php/config.php | 2 | ||||
| -rw-r--r-- | frontends/php/graph.php | 61 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 56 | ||||
| -rw-r--r-- | frontends/php/screenedit.php | 13 | ||||
| -rw-r--r-- | frontends/php/services.php | 11 | ||||
| -rw-r--r-- | frontends/php/srv_status.php | 2 |
9 files changed, 681 insertions, 264 deletions
diff --git a/frontends/php/chart.php b/frontends/php/chart.php index e4ed00f7..92485b1d 100644 --- a/frontends/php/chart.php +++ b/frontends/php/chart.php @@ -1,260 +1,597 @@ <?php include "include/config.inc.php"; -# PARAMETERS: - -# itemid -# period -# from - - if(isset($HTTP_GET_VARS["period"])) - { - $period=$HTTP_GET_VARS["period"]; - } - else + class Graph { - $period=3600; - } + var $period; + var $from; + var $sizeX; + var $sizeY; + var $itemid; + var $shiftX; + var $shiftY; + var $border; - if(isset($HTTP_GET_VARS["from"])) - { - $from=$HTTP_GET_VARS["from"]; - } - else - { - $from=0; - } + var $item; - if(isset($HTTP_GET_VARS["width"])&&$HTTP_GET_VARS["width"]>0) - { - $sizeX=$HTTP_GET_VARS["width"]; - } - else - { - $sizeX=900; - } + var $colors; + var $im; - $sizeY=200; + function initColors() + { + $this->colors["Red"]=ImageColorAllocate($this->im,255,0,0); + $this->colors["Dark Red"]=ImageColorAllocate($this->im,150,0,0); + $this->colors["Green"]=ImageColorAllocate($this->im,0,255,0); + $this->colors["Dark Green"]=ImageColorAllocate($this->im,0,150,0); + $this->colors["Blue"]=ImageColorAllocate($this->im,0,0,255); + $this->colors["Yellow"]=ImageColorAllocate($this->im,255,255,0); + $this->colors["Dark Yellow"]=ImageColorAllocate($this->im,150,150,0); + $this->colors["Cyan"]=ImageColorAllocate($this->im,0,255,255); + $this->colors["Black"]=ImageColorAllocate($this->im,0,0,0); + $this->colors["Gray"]=ImageColorAllocate($this->im,150,150,150); + $this->colors["White"]=ImageColorAllocate($this->im,255,255,255); + } - $shiftX=10; - $shiftY=17; + function Graph($itemid) + { + $this->period=3600; + $this->from=0; + $this->sizeX=900; + $this->sizeY=200; + $this->shiftX=10; + $this->shiftY=17; + $this->border=1; + $this->itemid=$itemid; + + $this->item=get_item_by_itemid($this->itemid); + $host=get_host_by_hostid($this->item["hostid"]); + $this->item["host"]=$host["host"]; + } - $nodata=1; + function setPeriod($period) + { + $this->period=$period; + } -// Header( "Content-type: text/html"); - Header( "Content-type: image/png"); - Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT"); + function setFrom($from) + { + $this->from=$from; + } - check_authorisation(); + function setWidth($width) + { + $this->width=$width; + } - $im = imagecreate($sizeX+$shiftX+61,$sizeY+2*$shiftY+40); - - $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); - $yellow=ImageColorAllocate($im,255,255,0); - $cyan=ImageColorAllocate($im,0,255,255); - $black=ImageColorAllocate($im,0,0,0); - $gray=ImageColorAllocate($im,150,150,150); - $white=ImageColorAllocate($im,255,255,255); + function setBorder($border) + { + $this->border=$border; + } - $x=imagesx($im); - $y=imagesy($im); - - ImageFilledRectangle($im,0,0,$sizeX+$shiftX+61,$sizeY+2*$shiftY+40,$white); - if(!isset($HTTP_GET_VARS["noborder"])) - { - ImageRectangle($im,0,0,$x-1,$y-1,$black); - } - if(!check_right("Item","R",$HTTP_GET_VARS["itemid"])) - { -// show_table_header("<font color=\"AA0000\">No permissions !</font>"); -// show_footer(); - ImagePng($im); - ImageDestroy($im); - exit; - } + function drawRectangle() + { + ImageFilledRectangle($this->im,0,0,$this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40,$this->colors["White"]); + if($this->border==1) + { + ImageRectangle($this->im,0,0,imagesx($this->im)-1,imagesy($this->im)-1,$this->colors["Black"]); + } + ImageDashedLine($this->im,$this->shiftX+1,$this->shiftY,$this->shiftX+1,$this->sizeY+$this->shiftY,$this->colors["Black"]); + ImageDashedLine($this->im,$this->shiftX+1,$this->shiftY,$this->shiftX+$this->sizeX,$this->shiftY,$this->colors["Black"]); + ImageDashedLine($this->im,$this->shiftX+$this->sizeX,$this->shiftY,$this->shiftX+$this->sizeX,$this->sizeY+$this->shiftY,$this->colors["Black"]); + ImageDashedLine($this->im,$this->shiftX+1,$this->shiftY+$this->sizeY,$this->shiftX+$this->sizeX,$this->sizeY+$this->shiftY,$this->colors["Black"]); + } -// for($i=0;$i<=$sizeY;$i+=$sizeY/5) -// { -// ImageDashedLine($im,$shiftX,$i+$shiftY,$sizeX+$shiftX,$i+$shiftY,$gray); -// } -// for($i=0;$i<=$sizeX;$i+=$sizeX/24) -// { -// ImageDashedLine($im,$i+$shiftX,$shiftY,$i+$shiftX,$sizeY+$shiftY,$gray); -// } -// $style=array($white,$white,$white,$white,$white,$white,$black,$black,$black,$black,$black,$black,$black); -// ImageSetStyle($im,$style); - ImageDashedLine($im,$shiftX+1,$shiftY,$shiftX+1,$sizeY+$shiftY,$black); - ImageDashedLine($im,$shiftX+1,$shiftY,$shiftX+$sizeX,$shiftY,$black); - ImageDashedLine($im,$shiftX+$sizeX,$shiftY,$shiftX+$sizeX,$sizeY+$shiftY,$black); - ImageDashedLine($im,$shiftX+1,$shiftY+$sizeY,$shiftX+$sizeX,$sizeY+$shiftY,$black); - - $item=get_item_by_itemid($HTTP_GET_VARS["itemid"]); - $host=get_host_by_hostid($item["hostid"]); - - $str=$host["host"].":".$item["description"]; - $x=imagesx($im)/2-ImageFontWidth(4)*strlen($str)/2; - ImageString($im, 4,$x,1, $str , $darkred); -// ImageString($im, 4,$sizeX/2-50,1, $host["host"].":".$item["description"] , $darkred); - - $from_time = time(NULL)-$period-3600*$from; - $to_time = time(NULL)-3600*$from; - $result=DBselect("select count(clock),min(clock),max(clock),min(value),max(value) from history where itemid=".$HTTP_GET_VARS["itemid"]." and clock>$from_time and clock<$to_time "); - $count=DBget_field($result,0,0); - if($count>0) - { - $nodata=0; - $minX=DBget_field($result,0,1); - $maxX=DBget_field($result,0,2); - $minY=DBget_field($result,0,3); - $maxY=DBget_field($result,0,4); - - } - else - { - unset($maxX); - unset($maxY); - unset($minX); - unset($minY); + function drawHeader() + { + $str=$this->item["host"].":".$this->item["description"]; + $x=imagesx($this->im)/2-ImageFontWidth(4)*strlen($str)/2; + ImageString($this->im, 4,$x,1, $str , $this->colors["Dark Red"]); + } - ImageString($im, 2,$sizeX/2-50, $sizeY+$shiftY+3, "NO DATA FOUND FOR THIS PERIOD" , $darkred); - ImageStringUp($im,0,imagesx($im)-10,imagesy($im)-50, "http://zabbix.sourceforge.net", $gray); + function noDataFound() + { + ImageString($this->im, 2,$this->sizeX/2-50, $this->sizeY+$this->shiftY+3, "NO DATA FOUND FOR THIS PERIOD" , $this->colors["Dark Red"]); + ImageStringUp($this->im,0,imagesx($this->im)-10,imagesy($this->im)-50, "http://zabbix.sourceforge.net", $this->colors["Gray"]); + ImagePng($this->im); + ImageDestroy($this->im); + } - ImagePng($im); - ImageDestroy($im); - exit; - } + function drawLogo() + { + ImageStringUp($this->im,0,imagesx($this->im)-10,imagesy($this->im)-50, "http://zabbix.sourceforge.net", $this->colors["Gray"]); + } - $my_exp = floor(log10($maxY)); - $my_mant = $maxY/pow(10,$my_exp); + function Draw() + { + $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40); + $nodata=1; - if ($my_mant < 1.5 ) - { - $my_mant = 1.5; - $my_steps = 5; - } - elseif($my_mant < 2 ) - { - $my_mant = 2; - $my_steps = 4; - } - elseif($my_mant < 3 ) - { - $my_mant = 3; - $my_steps = 6; - } - elseif($my_mant < 5 ) - { - $my_mant = 5; - $my_steps = 5; - } - elseif($my_mant < 8 ) - { - $my_mant = 8; - $my_steps = 4; - } - else - { - $my_mant = 10; - $my_steps = 5; - } - $maxY = $my_mant*pow(10,$my_exp); - $minY = 0; +// Header( "Content-type: text/html"); + Header( "Content-type: image/png"); + Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT"); + + check_authorisation(); + + $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40); + + $this->initColors(); + $this->drawRectangle(); + $this->drawHeader(); + + if(!check_right("Item","R",$this->itemid)) + { + ImagePng($this->im); + ImageDestroy($this->im); + exit; + } + + $from_time = time(NULL)-$this->period-3600*$this->from; + $to_time = time(NULL)-3600*$this->from; + $result=DBselect("select count(clock),min(clock),max(clock),min(value),max(value) from history where itemid=".$this->itemid." and clock>$from_time and clock<$to_time "); + $count=DBget_field($result,0,0); + if($count>0) + { + $nodata=0; + $minX=DBget_field($result,0,1); + $maxX=DBget_field($result,0,2); + $minY=DBget_field($result,0,3); + $maxY=DBget_field($result,0,4); + + } + else + { + $this->noDataFound(); + exit; + } + + $my_exp = floor(log10($maxY)); + $my_mant = $maxY/pow(10,$my_exp); + + if ($my_mant < 1.5 ) + { + $my_mant = 1.5; + $my_steps = 5; + } + elseif($my_mant < 2 ) + { + $my_mant = 2; + $my_steps = 4; + } + elseif($my_mant < 3 ) + { + $my_mant = 3; + $my_steps = 6; + } + elseif($my_mant < 5 ) + { + $my_mant = 5; + $my_steps = 5; + } + elseif($my_mant < 8 ) + { + $my_mant = 8; + $my_steps = 4; + } + else + { + $my_mant = 10; + $my_steps = 5; + } + $maxY = $my_mant*pow(10,$my_exp); + $minY = 0; // echo "MIN/MAX:",$minX," - ",$maxX," - ",$minY," - ",$maxY,"<Br>"; - if(isset($minX)&&($minX!=$maxX)&&($minY!=$maxY)) - { - $result=DBselect("select clock,value from history where itemid=".$HTTP_GET_VARS["itemid"]." and clock>$from_time and clock<$to_time order by clock"); - for($i=0;$i<DBnum_rows($result)-1;$i++) + if(isset($minX)&&($minX!=$maxX)&&($minY!=$maxY)) + { + $result=DBselect("select clock,value from history where itemid=".$this->itemid." and clock>$from_time and clock<$to_time order by clock"); + for($i=0;$i<DBnum_rows($result)-1;$i++) + { + $x=DBget_field($result,$i,0); + $x_next=DBget_field($result,$i+1,0); + $y=DBget_field($result,$i,1); + $y_next=DBget_field($result,$i+1,1); + + $x1=$this->sizeX*($x-$minX)/($maxX-$minX); + $y1=$this->sizeY*($y-$minY)/($maxY-$minY); + $x2=$this->sizeX*($x_next-$minX)/($maxX-$minX); + $y2=$this->sizeY*($y_next-$minY)/($maxY-$minY); + + $y1=$this->sizeY-$y1; + $y2=$this->sizeY-$y2; + + ImageLine($this->im,$x1+$this->shiftX,$y1+$this->shiftY,$x2+$this->shiftX,$y2+$this->shiftY,$this->colors["Dark Green"]); +// ImageSetPixel($this->im,$x2+$this->shiftX,$y2+$this->shiftY-1,$this->colors["Dark Red"]); + } + } + else + { + if(isset($minX)) + { + ImageLine($this->im,$this->shiftX,$this->shiftY+$this->sizeY/2,$this->sizeX+$this->shiftX,$this->shiftY+$this->sizeY/2,$this->colors["Dark Green"]); + } + } + + $startTime=$minX; + if (($maxX-$minX) < 300) + $precTime=10; + elseif (($maxX-$minX) < 3600 ) + $precTime=60; + else + $precTime=300; + + if (($maxX-$minX) < 1200 ) + $dateForm="H:i:s"; + else + $dateForm="H:i:s"; + + $correctTime=$startTime % $precTime; + $stepTime=ceil(ceil(($maxX-$minX)/20)/$precTime)*(1.0*$precTime); + + for($i=1;$i<$my_steps;$i++) + { + ImageDashedLine($this->im,$this->shiftX,$i/$my_steps*$this->sizeY+$this->shiftY,$this->sizeX+$this->shiftX,$i/$my_steps*$this->sizeY+$this->shiftY,$this->colors["Gray"]); + } + for($j=$stepTime-$correctTime;$j<=($maxX-$minX);$j+=$stepTime) + { + ImageDashedLine($this->im,$this->shiftX+($this->sizeX*$j)/($maxX-$minX),$this->shiftY,$this->shiftX+($this->sizeX*$j)/($maxX-$minX),$this->sizeY+$this->shiftY,$this->colors["Gray"]); + } + + + if($nodata == 0) + { + for($i=0;$i<=$my_steps;$i++) + { + ImageString($this->im, 1, $this->sizeX+5+$this->shiftX, $i/$my_steps*$this->sizeY+$this->shiftY-4, convert_units($maxY-$i/$my_steps*($maxY-$minY),$this->item["units"],$this->item["multiplier"]) , $this->colors["Dark Red"]); + } + for($j=$stepTime-$correctTime;$j<=($maxX-$minX);$j+=$stepTime) + { + ImageStringUp($this->im,0,$this->shiftX+($this->sizeX*$j)/($maxX-$minX),$this->shiftY+$this->sizeY+53,date($dateForm,$startTime+$j),$this->colors["Black"]); + } + + ImageString($this->im, 1,10, $this->sizeY+$this->shiftY+5, date("dS of F Y H:i:s",$minX) , $this->colors["Dark Red"]); + ImageString($this->im, 1,$this->sizeX+$this->shiftX-148,$this->sizeY+$this->shiftY+5, date("dS of F Y H:i:s",$maxX) , $this->colors["Dark Red"]); + } + else + { + ImageString($this->im, 2,$this->sizeX/2-50, $this->sizeY+$this->shiftY+3, "NO DATA FOUND FOR THIS PERIOD" , $this->colors["Dark Red"]); + } + + $this->drawLogo(); + + + ImagePng($this->im); + ImageDestroy($this->im); + } + + function Draw2() { - $x=DBget_field($result,$i,0); - $x_next=DBget_field($result,$i+1,0); - $y=DBget_field($result,$i,1); - $y_next=DBget_field($result,$i+1,1); + $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40); + $nodata=1; + + Header( "Content-type: text/html"); +// Header( "Content-type: image/png"); + Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT"); - $x1=$sizeX*($x-$minX)/($maxX-$minX); - $y1=$sizeY*($y-$minY)/($maxY-$minY); - $x2=$sizeX*($x_next-$minX)/($maxX-$minX); - $y2=$sizeY*($y_next-$minY)/($maxY-$minY); + check_authorisation(); + + $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40); + + $this->initColors(); + $this->drawRectangle(); + $this->drawHeader(); + + if(!check_right("Item","R",$this->itemid)) + { + ImagePng($this->im); + ImageDestroy($this->im); + exit; + } + + $from_time = time(NULL)-$this->period-3600*$this->from; + $to_time = time(NULL)-3600*$this->from; + + for($i=0;$i<=$this->sizeX;$i+=$this->sizeX/24) + { +// ImageDashedLine($this->im,$i+$this->shiftX,$this->shiftY,$i+$this->shiftX,$this->sizeY+$this->shiftY,$this->colors["Gray"]); + $label_format="H:i"; + ImageString($this->im, 1,$i+$this->shiftX-11, $this->sizeY+$this->shiftY+5, date($label_format,$from_time+$this->period*($i/$this->sizeX)) , $this->colors["Black"]); + } + + $p=$to_time-$from_time; + $z=$from_time%$p; + $count=array(); + $min=array(); + $max=array(); + $avg=array(); + + $sql="select round(900*((clock+$z)%($p))/($p)) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max from history where itemid=".$this->itemid ." and clock>$from_time and clock<$to_time group by round(900*((clock+$z)%($p))/($p))"; + $result=DBselect($sql); + while($row=DBfetch($result)) + { + $i=$row["i"]; + $count[$i]=$row["count"]; + $min[$i]=$row["min"]; + $max[$i]=$row["max"]; + $avg[$i]=$row["avg"]; + $nodata=0; + } + + if($nodata!=0) + { + $this->noDataFound(); + exit; + } - $y1=$sizeY-$y1; - $y2=$sizeY-$y2; +// echo "MIN/MAX:",$minX," - ",$maxX," - ",$minY," - ",$maxY,"<Br>"; + $minX=0; + $maxX=900; + $maxY=max($avg); + $minY=min($avg); - ImageLine($im,$x1+$shiftX,$y1+$shiftY,$x2+$shiftX,$y2+$shiftY,$darkgreen); -// ImageSetPixel($im,$x2+$shiftX,$y2+$shiftY-1,$darkred); - } - } - else + if(isset($minY)&&($maxY)&&($minX!=$maxX)&&($minY!=$maxY)) { - if(isset($minX)) + for($i=0;$i<900;$i++) { - ImageLine($im,$shiftX,$shiftY+$sizeY/2,$sizeX+$shiftX,$shiftY+$sizeY/2,$darkgreen); + if($count[$i]>0) + { + $x1=$this->sizeX*($i-$minX)/($maxX-$minX); + $y1=$this->sizeY*($avg[$i]-$minY)/($maxY-$minY); + $x1=$this->sizeX-$x1; + $y1=$this->sizeY-$y1; + + for($j=$i-1;$j>=0;$j--) + { + if($count[$j]>0) + { + $x2=$this->sizeX*($j-$minX)/($maxX-$minX); + $y2=$this->sizeY*($avg[$j]-$minY)/($maxY-$minY); + $x2=$this->sizeX-$x2; + $y2=$this->sizeY-$y2; + ImageLine($this->im,$x1+$this->shiftX,$y1+$this->shiftY,$x2+$this->shiftX,$y2+$this->shiftY,$this->colors["Dark Green"]); + break; + } + } + } +// echo $this->sizeX*($i-$minX)/($maxX-$minX),":",$y1,"<br>"; } } - $startTime=$minX; - if (($maxX-$minX) < 300) - $precTime=10; - elseif (($maxX-$minX) < 3600 ) - $precTime=60; - else - $precTime=300; + $startTime=$minX; + if (($maxX-$minX) < 300) + $precTime=10; + elseif (($maxX-$minX) < 3600 ) + $precTime=60; + else + $precTime=300; + + if (($maxX-$minX) < 1200 ) + $dateForm="H:i:s"; + else + $dateForm="H:i:s"; + + $correctTime=$startTime % $precTime; + $stepTime=ceil(ceil(($maxX-$minX)/20)/$precTime)*(1.0*$precTime); + +/* for($i=1;$i<$my_steps;$i++) + { + ImageDashedLine($this->im,$this->shiftX,$i/$my_steps*$this->sizeY+$this->shiftY,$this->sizeX+$this->shiftX,$i/$my_steps*$this->sizeY+$this->shiftY,$this->colors["Gray"]); + } + for($j=$stepTime-$correctTime;$j<=($maxX-$minX);$j+=$stepTime) + { + ImageDashedLine($this->im,$this->shiftX+($this->sizeX*$j)/($maxX-$minX),$this->shiftY,$this->shiftX+($this->sizeX*$j)/($maxX-$minX),$this->sizeY+$this->shiftY,$this->colors["Gray"]); + }*/ + + + if($nodata == 0) + { +/* for($i=0;$i<=$my_steps;$i++) + { + ImageString($this->im, 1, $this->sizeX+5+$this->shiftX, $i/$my_steps*$this->sizeY+$this->shiftY-4, convert_units($maxY-$i/$my_steps*($maxY-$minY),$this->item["units"],$this->item["multiplier"]) , $this->colors["Dark Red"]); + }*/ + for($j=$stepTime-$correctTime;$j<=($maxX-$minX);$j+=$stepTime) + { +// ImageStringUp($this->im,0,$this->shiftX+($this->sizeX*$j)/($maxX-$minX),$this->shiftY+$this->sizeY+53,date($dateForm,$startTime+$j),$this->colors["Black"]); + } + +// ImageString($this->im, 1,10, $this->sizeY+$this->shiftY+5, date("dS of F Y H:i:s",$minX) , $this->colors["Dark Red"]); +// ImageString($this->im, 1,$this->sizeX+$this->shiftX-148,$this->sizeY+$this->shiftY+5, date("dS of F Y H:i:s",$maxX) , $this->colors["Dark Red"]); + } + else + { + ImageString($this->im, 2,$this->sizeX/2-50, $this->sizeY+$this->shiftY+3, "NO DATA FOUND FOR THIS PERIOD" , $this->colors["Dark Red"]); + } + + $this->drawLogo(); + + + ImagePng($this->im); + ImageDestroy($this->im); + } + + function Draw3() + { + $start_time=time(NULL); - if (($maxX-$minX) < 1200 ) - $dateForm="H:i:s"; - else - $dateForm="H:i:s"; + $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40); + $nodata=1; - $correctTime=$startTime % $precTime; - $stepTime=ceil(ceil(($maxX-$minX)/20)/$precTime)*(1.0*$precTime); +// Header( "Content-type: text/html"); + Header( "Content-type: image/png"); + Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT"); - for($i=1;$i<$my_steps;$i++) + check_authorisation(); + + $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40); + + $this->initColors(); + $this->drawRectangle(); + $this->drawHeader(); + if(!check_right("Item","R",$this->itemid)) + { + ImagePng($this->im); + ImageDestroy($this->im); + exit; + } + + $now = time(NULL); +// $to_time=$now-$now%$this->period; + $to_time=$now; +// $from_time=$to_time-17*$this->period; + $from_time=$to_time-$this->period; + + $count=array(); + $min=array(); + $max=array(); + $avg=array(); + $p=$to_time-$from_time; +// $z=$from_time%$p; + $z=$p-$from_time%$p; + $sql="select round(900*((clock+$z)%($p))/($p)) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max from history where itemid=".$this->item["itemid"]." and clock>=$from_time and clock<=$to_time group by round(900*((clock+$z)%($p))/($p))"; +// $sql="select round(900*((clock+3*3600)%(3600))/(3600)) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max from history where itemid=".$this->item["itemid"]." and clock>=$from_time and clock<=$to_time group by round(900*((clock+3*3600)%($p))/($p))"; +// echo $sql,"<br>"; +// echo $to_time-$from_time,"<br>"; + + $result=DBselect($sql); + while($row=DBfetch($result)) + { + $i=$row["i"]; + $count[$i]=$row["count"]; + $min[$i]=$row["min"]; + $max[$i]=$row["max"]; + $avg[$i]=$row["avg"]; + $nodata=0; + } + + + for($i=0;$i<=$this->sizeY;$i+=$this->sizeY/6) + { + ImageDashedLine($this->im,$this->shiftX,$i+$this->shiftY,$this->sizeX+$this->shiftX,$i+$this->shiftY,$this->colors["Gray"]); + } + + for($i=0;$i<=$this->sizeX;$i+=$this->sizeX/24) + { + ImageDashedLine($this->im,$i+$this->shiftX,$this->shiftY,$i+$this->shiftX,$this->sizeY+$this->shiftY,$this->colors["Gray"]); + if($nodata == 0) + { + $label_format="H:i"; + ImageString($this->im, 1,$i+$this->shiftX-11, $this->sizeY+$this->shiftY+5, date($label_format,$from_time+$i*$this->period/$this->sizeX) , $this->colors["Black"]); +// echo $from_time," ",$to_time," ",$from_time+$i*$this->period/$this->sizeX,"<br>"; + } + } + + $maxX=900; + $minX=0; + $maxY=max($max); + $minY=min($min); + $minY=0; +// $maxY=30000; + # echo "MIN/MAX:",$minX," - ",$maxX," - ",$minY," - ",$maxY,"<Br>"; + + if(isset($minY)&&($maxY)&&($minX!=$maxX)&&($minY!=$maxY)) + { + for($i=0;$i<900;$i++) + { + if($count[$i]>0) + { + $x1=$this->sizeX*($i-$minX)/($maxX-$minX); + $y1=$this->sizeY*($max[$i]-$minY)/($maxY-$minY); + $y1=$this->sizeY-$y1; + for($j=$i-1;$j>=0;$j--) + { + if($count[$j]>0) + { + $x2=$this->sizeX*($j-$minX)/($maxX-$minX); + $y2=$this->sizeY*($max[$j]-$minY)/($maxY-$minY); + $y2=$this->sizeY-$y2; + ImageLine($this->im,$x1+$this->shiftX,$y1+$this->shiftY,$x2+$this->shiftX,$y2+$this->shiftY,$this->colors["Dark Red"]); + break; + } + } + + $x1=$this->sizeX*($i-$minX)/($maxX-$minX); + $y1=$this->sizeY*($avg[$i]-$minY)/($maxY-$minY); + $y1=$this->sizeY-$y1; + for($j=$i-1;$j>=0;$j--) + { + if($count[$j]>0) + { + $x2=$this->sizeX*($j-$minX)/($maxX-$minX); + $y2=$this->sizeY*($avg[$j]-$minY)/($maxY-$minY); + $y2=$this->sizeY-$y2; + ImageLine($this->im,$x1+$this->shiftX,$y1+$this->shiftY,$x2+$this->shiftX,$y2+$this->shiftY,$this->colors["Dark Yellow"]); + break; + } + } + + $x1=$this->sizeX*($i-$minX)/($maxX-$minX); + $y1=$this->sizeY*($min[$i]-$minY)/($maxY-$minY); + $y1=$this->sizeY-$y1; + for($j=$i-1;$j>=0;$j--) + { + if($count[$j]>0) + { + $x2=$this->sizeX*($j-$minX)/($maxX-$minX); + $y2=$this->sizeY*($min[$j]-$minY)/($maxY-$minY); + $y2=$this->sizeY-$y2; + ImageLine($this->im,$x1+$this->shiftX,$y1+$this->shiftY,$x2+$this->shiftX,$y2+$this->shiftY,$this->colors["Dark Green"]); + break; + } + } + } + } + } + + if($nodata == 0) + { + for($i=0;$i<=$this->sizeY;$i+=$this->sizeY/6) + { + ImageString($this->im, 1, $this->sizeX+5+$this->shiftX, $this->sizeY-$i-4+$this->shiftY, convert_units($i*($maxY-$minY)/$this->sizeY+$minY,$this->item["units"],$this->item["multiplier"]) , $this->colors["Dark Red"]); + } + + // date("dS of F Y h:i:s A",DBget_field($result,0,0)); + + // 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($this->im, 2,$this->sizeX/2 -50,$this->sizeY+$this->shiftY+3, "NO DATA FOR THIS PERIOD" , $this->colors["Dark Red"]); + } + + ImageString($this->im, 1,$this->shiftX, $this->sizeY+$this->shiftY+15, "MIN" , $this->colors["Dark Green"]); + ImageString($this->im, 1,$this->shiftX+20, $this->sizeY+$this->shiftY+15, "AVG" , $this->colors["Dark Yellow"]); + ImageString($this->im, 1,$this->shiftX+40, $this->sizeY+$this->shiftY+15, "MAX" , $this->colors["Dark Red"]); + + ImageStringUp($this->im,0,imagesx($this->im)-10,imagesy($this->im)-50, "http://zabbix.sourceforge.net", $this->colors["Gray"]); + + $end_time=time(NULL); + ImageString($this->im, 0,imagesx($this->im)-100,imagesy($this->im)-12,"Generated in ".($end_time-$start_time)." sec", $this->colors["Gray"]); + + ImagePng($this->im); + ImageDestroy($this->im); + } + } + + $graph=new Graph($HTTP_GET_VARS["itemid"]); + if(isset($HTTP_GET_VARS["period"])) { - ImageDashedLine($im,$shiftX,$i/$my_steps*$sizeY+$shiftY,$sizeX+$shiftX,$i/$my_steps*$sizeY+$shiftY,$gray); + $graph->setPeriod($HTTP_GET_VARS["period"]); } - for($j=$stepTime-$correctTime;$j<=($maxX-$minX);$j+=$stepTime) + if(isset($HTTP_GET_VARS["from"])) { - ImageDashedLine($im,$shiftX+($sizeX*$j)/($maxX-$minX),$shiftY,$shiftX+($sizeX*$j)/($maxX-$minX),$sizeY+$shiftY,$gray); + $graph->setFrom($HTTP_GET_VARS["from"]); } - - - if($nodata == 0) + if(isset($HTTP_GET_VARS["width"])) { -// for($i=0;$i<=$sizeY;$i+=$sizeY/5) -// { -// ImageString($im, 1, $sizeX+5+$shiftX, $sizeY-$i-4+$shiftY, $i*($maxY-$minY)/$sizeY+$minY , $darkred); -// } -// for($i=0;$i<=$sizeX;$i+=$sizeX/24) -// { -// ImageStringUp($im,0,$i+$shiftX-3,$shiftY+$sizeY+50,date("H:i:s",$i*($maxX-$minX)/$sizeX+$minX),$black); -// } - - for($i=0;$i<=$my_steps;$i++) - { - ImageString($im, 1, $sizeX+5+$shiftX, $i/$my_steps*$sizeY+$shiftY-4, convert_units($maxY-$i/$my_steps*($maxY-$minY),$item["units"],$item["multiplier"]) , $darkred); - } - for($j=$stepTime-$correctTime;$j<=($maxX-$minX);$j+=$stepTime) - { - ImageStringUp($im,0,$shiftX+($sizeX*$j)/($maxX-$minX),$shiftY+$sizeY+53,date($dateForm,$startTime+$j),$black); - } - -// ImageString($im, 1,10, $sizeY+$shiftY+3, date("dS of F Y",$minX) , $darkred); -// ImageString($im, 1,$sizeX+$shiftX-90,$sizeY+$shiftY+3, date("dS of F Y",$maxX) , $darkred); - ImageString($im, 1,10, $sizeY+$shiftY+5, date("dS of F Y H:i:s",$minX) , $darkred); - ImageString($im, 1,$sizeX+$shiftX-148,$sizeY+$shiftY+5, date("dS of F Y H:i:s",$maxX) , $darkred); + $graph->setWidth($HTTP_GET_VARS["width"]); } - else + if(isset($HTTP_GET_VARS["border"])) { - ImageString($im, 2,$sizeX/2-50, $sizeY+$shiftY+3, "NO DATA FOUND FOR THIS PERIOD" , $darkred); + $graph->setBorder(0); } - ImageStringUp($im,0,imagesx($im)-10,imagesy($im)-50, "http://zabbix.sourceforge.net", $gray); - - ImagePng($im); - ImageDestroy($im); + $graph->Draw3(); ?> + diff --git a/frontends/php/chart2.php b/frontends/php/chart2.php index 980fe15b..0489fcc0 100644 --- a/frontends/php/chart2.php +++ b/frontends/php/chart2.php @@ -118,6 +118,7 @@ $x=array(); $y=array(); $desc=array(); + $iids=array(); $color=array(); $drawtype=array(); @@ -129,6 +130,7 @@ for($item=0;$item<DBnum_rows($result2);$item++) { $itemid=DBget_field($result2,$item,0); + $iids[$item]=$itemid; $desc[$item]=DBget_field($result2,$item,1); $color[$item]=DBget_field($result2,$item,2); $host[$item]=DBget_field($result2,$item,3); @@ -172,7 +174,7 @@ $maxY = $HTTP_GET_VARS["force_maxy"]; } - $my_exp = floor(log10($maxY)); + $my_exp=iif($maxY!=0,floor(log10($maxY)),0); $my_mant = $maxY/pow(10,$my_exp); if ($my_mant < 1.5 ) @@ -292,7 +294,19 @@ } ImageFilledRectangle($im,$shiftX,$sizeY+$shiftYup+19+15*$item+45,$shiftX+5,$sizeY+$shiftYup+15+9+15*$item+45,$colors[$color[$item]]); ImageRectangle($im,$shiftX,$sizeY+$shiftYup+19+15*$item+45,$shiftX+5,$sizeY+$shiftYup+15+9+15*$item+45,$black); - $str=sprintf("%s: %s [min:%.2f, avg:%.2f, max:%.2f]", $host[$item], $desc[$item], $itemMin, $itemAvg, $itemMax); +// ImageString($im, 1, $sizeX+5+$shiftX, $i/$my_steps*$sizeY+$shiftYup-4, convert_units($maxY-$i/$my_steps*($maxY-$minY),$z["units"],$z["multiplier"]) , $darkred); +// $str=sprintf("%s: %s [min:%.2f, avg:%.2f, max:%.2f]", $host[$item], $desc[$item], $itemMin, $itemAvg, $itemMax); + $max_host_len=0; + $max_desc_len=0; + for($i=0;$i<DBnum_rows($result2);$i++) + { + $z=get_item_by_itemid($iids[$i]); + $h=get_host_by_hostid($z["hostid"]); + if(strlen($h["host"])>$max_host_len) $max_host_len=strlen($h["host"]); + if(strlen($z["description"])>$max_desc_len) $max_desc_len=strlen($z["description"]); + } + $i=get_item_by_itemid($iids[$item]); + $str=sprintf("%s: %s [last:%s min:%s avg:%s max:%s]", str_pad($host[$item],$max_post_len," "), str_pad($desc[$item],$max_desc_len," "), convert_units($y[$item][$len[$item]-1],$i["units"],$i["multiplier"]), convert_units($itemMin,$i["units"],$i["multiplier"]), convert_units($itemAvg,$i["units"],$i["multiplier"]), convert_units($itemMax,$i["units"],$i["multiplier"])); if($width>600) { ImageString($im, 2,$shiftX+9,$sizeY+$shiftYup+15*$item+15+45,$str, $black); diff --git a/frontends/php/charts.php b/frontends/php/charts.php index c8e00f12..7420d92a 100644 --- a/frontends/php/charts.php +++ b/frontends/php/charts.php @@ -64,13 +64,22 @@ { $result=DBselect("select name from graphs where graphid=".$HTTP_GET_VARS["graphid"]); $row=DBfetch($result); + $str=""; + if(isset($HTTP_GET_VARS["from"])) + { + $str=$str."&from=".$HTTP_GET_VARS["from"]; + } + if(isset($HTTP_GET_VARS["period"])) + { + $str=$str."&period=".$HTTP_GET_VARS["period"]; + } if(isset($HTTP_GET_VARS["fullscreen"])) { - $map="<a href=\"charts.php?graphid=".$HTTP_GET_VARS["graphid"]."\">".$row["name"]."</a>"; + $map="<a href=\"charts.php?graphid=".$HTTP_GET_VARS["graphid"]."$str\">".$row["name"]."</a>"; } else { - $map="<a href=\"charts.php?graphid=".$HTTP_GET_VARS["graphid"]."&fullscreen=1\">".$row["name"]."</a>"; + $map="<a href=\"charts.php?graphid=".$HTTP_GET_VARS["graphid"]."&fullscreen=1$str\">".$row["name"]."</a>"; } } else diff --git a/frontends/php/config.php b/frontends/php/config.php index a1325f80..50288e61 100644 --- a/frontends/php/config.php +++ b/frontends/php/config.php @@ -194,7 +194,7 @@ echo "<input class=\"biginput\" name=\"smtp_email\" type=\"hidden\" value=\"$smtp_email\">"; show_table2_v_delimiter(); - echo "Script path"; + echo "Script name"; show_table2_h_delimiter(); echo "<input class=\"biginput\" name=\"exec_path\" value=\"".$exec_path."\" size=50>"; } diff --git a/frontends/php/graph.php b/frontends/php/graph.php index e31bdb0c..3b80876c 100644 --- a/frontends/php/graph.php +++ b/frontends/php/graph.php @@ -27,6 +27,11 @@ $result=add_item_to_graph($HTTP_GET_VARS["graphid"],$HTTP_GET_VARS["itemid"],$HTTP_GET_VARS["color"],$HTTP_GET_VARS["drawtype"]); show_messages($result,"Item added","Cannot add item"); } + if($HTTP_GET_VARS["register"]=="update") + { + $result=update_graph_item($HTTP_GET_VARS["gitemid"],$HTTP_GET_VARS["itemid"],$HTTP_GET_VARS["color"],$HTTP_GET_VARS["drawtype"]); + show_messages($result,"Item updated","Cannot update item"); + } if($HTTP_GET_VARS["register"]=="delete") { $result=delete_graphs_item($HTTP_GET_VARS["gitemid"]); @@ -69,7 +74,11 @@ echo "<TD><a href=\"chart.php?itemid=".$row["itemid"]."&period=3600&from=0\">".$row["description"]."</a></TD>"; echo "<TD>".get_drawtype_description($row["drawtype"])."</TD>"; echo "<TD>".$row["color"]."</TD>"; - echo "<TD><A HREF=\"graph.php?register=delete&graphid=".$HTTP_GET_VARS["graphid"]."&gitemid=".$row["gitemid"]."\">Delete</A></TD>"; + echo "<TD>"; + echo "<A HREF=\"graph.php?graphid=".$HTTP_GET_VARS["graphid"]."&gitemid=".$row["gitemid"]."#form\">Change</A>"; + echo " - "; + echo "<A HREF=\"graph.php?register=delete&graphid=".$HTTP_GET_VARS["graphid"]."&gitemid=".$row["gitemid"]."\">Delete</A>"; + echo "</TD>"; echo "</TR>"; } echo "</TABLE>"; @@ -79,6 +88,15 @@ echo "<br>"; echo "<a name=\"form\"></a>"; + if(isset($HTTP_GET_VARS["gitemid"])) + { + $sql="select itemid,color,drawtype from graphs_items where gitemid=".$HTTP_GET_VARS["gitemid"]; + $result=DBselect($sql); + $itemid=DBget_field($result,0,0); + $color=DBget_field($result,0,1); + $drawtype=DBget_field($result,0,2); + } + show_table2_header_begin(); echo "New item for graph"; @@ -99,7 +117,14 @@ $host_=DBget_field($result,$i,0); $description_=DBget_field($result,$i,1); $itemid_=DBget_field($result,$i,2); - echo "<OPTION VALUE='$itemid_'>$host_: $description_"; + if(isset($itemid)&&($itemid==$itemid_)) + { + echo "<OPTION VALUE='$itemid_' SELECTED>$host_: $description_"; + } + else + { + echo "<OPTION VALUE='$itemid_'>$host_: $description_"; + } } echo "</SELECT>"; @@ -107,30 +132,34 @@ echo "Type"; show_table2_h_delimiter(); echo "<select name=\"drawtype\" size=1>"; - echo "<OPTION VALUE='0'>".get_drawtype_description(0); - echo "<OPTION VALUE='1'>".get_drawtype_description(1); - echo "<OPTION VALUE='2'>".get_drawtype_description(2); + echo "<OPTION VALUE='0' ".iif(isset($drawtype)&&($drawtype==0),"SELECTED","").">".get_drawtype_description(0); + echo "<OPTION VALUE='1' ".iif(isset($drawtype)&&($drawtype==1),"SELECTED","").">".get_drawtype_description(1); + echo "<OPTION VALUE='2' ".iif(isset($drawtype)&&($drawtype==2),"SELECTED","").">".get_drawtype_description(2); echo "</SELECT>"; show_table2_v_delimiter(); echo "Color"; show_table2_h_delimiter(); echo "<select name=\"color\" size=1>"; - echo "<OPTION VALUE='Black'>Black"; - echo "<OPTION VALUE='Blue'>Blue"; - echo "<OPTION VALUE='Cyan'>Cyan"; - echo "<OPTION VALUE='Dark Blue'>Dark blue"; - echo "<OPTION VALUE='Dark Green'>Dark green"; - echo "<OPTION VALUE='Dark Red'>Dark red"; - echo "<OPTION VALUE='Dark Yellow'>Dark yellow"; - echo "<OPTION VALUE='Green'>Green"; - echo "<OPTION VALUE='Red'>Red"; - echo "<OPTION VALUE='White'>White"; - echo "<OPTION VALUE='Yellow'>Yellow"; + echo "<OPTION VALUE='Black' ".iif(isset($color)&&($color=="Black"),"SELECTED","").">Black"; + echo "<OPTION VALUE='Blue' ".iif(isset($color)&&($color=="Blue"),"SELECTED","").">Blue"; + echo "<OPTION VALUE='Cyan' ".iif(isset($color)&&($color=="Cyan"),"SELECTED","").">Cyan"; + echo "<OPTION VALUE='Dark Blue' ".iif(isset($color)&&($color=="Dark Blue"),"SELECTED","").">Dark blue"; + echo "<OPTION VALUE='Dark Green' ".iif(isset($color)&&($color=="Dark Green"),"SELECTED","").">Dark green"; + echo "<OPTION VALUE='Dark Red' ".iif(isset($color)&&($color=="Dark Red"),"SELECTED","").">Dark red"; + echo "<OPTION VALUE='Dark Yellow' ".iif(isset($color)&&($color=="Dark Yellow"),"SELECTED","")."'>Dark yellow"; + echo "<OPTION VALUE='Green' ".iif(isset($color)&&($color=="Green"),"SELECTED","").">Green"; + echo "<OPTION VALUE='Red' ".iif(isset($color)&&($color=="Red"),"SELECTED","").">Red"; + echo "<OPTION VALUE='White' ".iif(isset($color)&&($color=="White"),"SELECTED","").">White"; + echo "<OPTION VALUE='Yellow' ".iif(isset($color)&&($color=="Yellow"),"SELECTED","").">Yellow"; echo "</SELECT>"; show_table2_v_delimiter2(); echo "<input type=\"submit\" name=\"register\" value=\"add\">"; + if(isset($itemid)) + { + echo "<input type=\"submit\" name=\"register\" value=\"update\">"; + } show_table2_header_end(); ?> diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 3d52da01..27258313 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -573,6 +573,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; } echo "<center>"; // echo "<font size=+1 color='$color'>"; + echo "<font color='$color'>"; if($ERROR_MSG=="") { echo "<b>[$msg]</b>"; @@ -581,7 +582,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; { echo "<b>[$msg. $ERROR_MSG]</b>"; } -// echo "</font>"; + echo "</font>"; echo "</center><br>"; } @@ -901,11 +902,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; if( ($page["file"]=="latest.php") || ($page["file"]=="history.php")) { - echo "<b>[LATEST VALUES]</b></a>"; + echo "<b>[LATEST VALUES]</b></a>"; } else { - echo "LATEST VALUES</a>"; + echo "LATEST VALUES</a>"; } ?> </td> @@ -988,11 +989,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; <?php if($page["file"]=="maps.php") { - echo "<b>[NETWORK MAPS]</b></a>"; + echo "<b>[NETWORK MAPS]</b></a>"; } else { - echo "NETWORK MAPS</a>"; + echo "NETWORK MAPS</a>"; } ?> </td> @@ -1041,11 +1042,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; } if($page["file"]=="srv_status.php") { - echo "<b>[IT SERVICES]</b></a>"; + echo "<b>[IT SERVICES]</b></a>"; } else { - echo "IT SERVICES</a>"; + echo "IT SERVICES</a>"; } ?> </td> @@ -1093,11 +1094,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; <?php if($page["file"]=="report1.php") { - echo "<b>[STATUS OF ZABBIX]</b></a>"; + echo "<b>[STATUS OF ZABBIX]</b></a>"; } else { - echo "STATUS OF ZABBIX</a>"; + echo "STATUS OF ZABBIX</a>"; } ?> </td> @@ -1111,11 +1112,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; <?php if($page["file"]=="report2.php") { - echo "<b>[AVAILABILITY REPORT]</b></a>"; + echo "<b>[AVAILABILITY REPORT]</b></a>"; } else { - echo "AVAILABILITY REPORT</a>"; + echo "AVAILABILITY REPORT</a>"; } ?> </td> @@ -1231,11 +1232,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; if( ($page["file"]=="sysmaps.php")|| ($page["file"]=="sysmap.php")) { - echo "<b>[NETWORK MAPS]</b></a>"; + echo "<b>[NETWORK MAPS]</b></a>"; } else { - echo "NETWORK MAPS</a>"; + echo "NETWORK MAPS</a>"; } ?> </td> @@ -1282,11 +1283,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; } if($page["file"]=="services.php") { - echo "<b>[IT SERVICES]</b></a>"; + echo "<b>[IT SERVICES]</b></a>"; } else { - echo "IT SERVICES</a>"; + echo "IT SERVICES</a>"; } ?> </td> @@ -1805,13 +1806,19 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; function add_service_link($servicedownid,$serviceupid,$softlink) { -// global $ERROR_MSG; + global $ERROR_MSG; if( ($softlink==0) && (is_service_hardlinked($servicedownid)==TRUE) ) { return FALSE; } + if($servicedownid==$serviceupid) + { + $ERROR_MSG="Cannot link service to itself."; + return FALSE; + } + $sql="insert into services_links (servicedownid,serviceupid,soft) values ($servicedownid,$serviceupid,$softlink)"; return DBexecute($sql); } @@ -2326,6 +2333,12 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; return DBexecute($sql); } + function update_graph_item($gitemid,$itemid,$color,$drawtype) + { + $sql="update graphs_items set itemid=$itemid,color='$color',drawtype=$drawtype where gitemid=$gitemid"; + return DBexecute($sql); + } + function add_item_to_graph($graphid,$itemid,$color,$drawtype) { $sql="insert into graphs_items (graphid,itemid,color,drawtype) values ($graphid,$itemid,'$color',$drawtype)"; @@ -4220,18 +4233,28 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; { return $result; } + $sql="delete from screens_graphs where screenid=$screenid"; + $result=DBexecute($sql); + if(!$result) + { + return $result; + } $sql="delete from screens where screenid=$screenid"; return DBexecute($sql); } function add_screen_item($screenid,$x,$y,$graphid,$width,$height) { + $sql="delete from screens_items where screenid=$screenid and x=$x and y=$y"; + DBexecute($sql); $sql="insert into screens_items (screenid,x,y,graphid,width,height) values ($screenid,$x,$y,$graphid,$width,$height)"; return DBexecute($sql); } function add_screen_graph($screenid,$x,$y,$itemid,$width,$height) { + $sql="delete from screens_graphs where screenid=$screenid and x=$x and y=$y"; + DBexecute($sql); $sql="insert into screens_graphs (screenid,x,y,itemid,width,height) values ($screenid,$x,$y,$itemid,$width,$height)"; return DBexecute($sql); } @@ -4248,7 +4271,6 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid"; return DBexecute($sql); } - function get_drawtype_description($drawtype) { if($drawtype==0) diff --git a/frontends/php/screenedit.php b/frontends/php/screenedit.php index e042418c..55b7255e 100644 --- a/frontends/php/screenedit.php +++ b/frontends/php/screenedit.php @@ -24,10 +24,11 @@ { if($HTTP_GET_VARS["register"]=="add") { - if(isset($HTTP_GET_VARS["screenitemid"])) - { - delete_screen_item($HTTP_GET_VARS["screenitemid"]); - } +// if(isset($HTTP_GET_VARS["screenitemid"])) +// { +// delete_screen_item($HTTP_GET_VARS["screenitemid"]); +// unset($HTTP_GET_VARS["screenitemid"]); +// } if($HTTP_GET_VARS["resource"]==0) { $result=add_screen_graph($HTTP_GET_VARS["screenid"],$HTTP_GET_VARS["x"],$HTTP_GET_VARS["y"],$HTTP_GET_VARS["itemid"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]); @@ -36,6 +37,7 @@ { $result=add_screen_item($HTTP_GET_VARS["screenid"],$HTTP_GET_VARS["x"],$HTTP_GET_VARS["y"],$HTTP_GET_VARS["graphid"],$HTTP_GET_VARS["width"],$HTTP_GET_VARS["height"]); } + unset($HTTP_GET_VARS["x"]); show_messages($result,"Item added","Cannot add item"); } if($HTTP_GET_VARS["register"]=="delete") @@ -113,6 +115,7 @@ echo "<input name=\"x\" type=\"hidden\" value=$c>"; echo "<input name=\"y\" type=\"hidden\" value=$r>"; echo "<input name=\"screenitemid\" type=\"hidden\" value=$screenitemid>"; + echo "<input name=\"screengraphid\" type=\"hidden\" value=$screengraphid>"; echo "<input name=\"resource\" type=\"hidden\" value=$resource>"; show_table2_v_delimiter(); @@ -137,7 +140,7 @@ $host_=DBget_field($result,$i,0); $description_=DBget_field($result,$i,1); $itemid_=DBget_field($result,$i,2); - echo "<OPTION VALUE='$itemid_ ".iif($itemid==$itemid_,"selected","")."'>$host_: $description_"; + echo "<OPTION VALUE='$itemid_' ".iif($itemid==$itemid_,"selected","")."'>$host_: $description_"; } echo "</SELECT>"; } diff --git a/frontends/php/services.php b/frontends/php/services.php index 2ed2847d..5c7687d7 100644 --- a/frontends/php/services.php +++ b/frontends/php/services.php @@ -202,13 +202,13 @@ $showsla=0; $goodsla=99.05; $sortorder=0; - unset($HTTP_GET_VARS["triggerid"]); + unset($triggerid); } echo "<br>"; echo "<a name=\"form\"></a>"; show_table2_header_begin(); - echo "New service"; + echo "Service"; show_table2_v_delimiter(); echo "<form method=\"get\" action=\"services.php\">"; @@ -277,7 +277,7 @@ show_table2_v_delimiter(); echo "Link to trigger ?"; show_table2_h_delimiter(); - if(isset($HTTP_GET_VARS["triggerid"])&&($HTTP_GET_VARS["triggerid"]!="")) + if(isset($triggerid)&&($triggerid!="")) { echo "<INPUT class=\"biginput\" TYPE=\"CHECKBOX\" NAME=\"linktrigger\" VALUE=\"on\" CHECKED>"; } @@ -318,7 +318,10 @@ show_table2_v_delimiter2(); - echo "<input type=\"submit\" name=\"register\" value=\"add\">"; + if(!isset($triggerid)||($triggerid=="")) + { + echo "<input type=\"submit\" name=\"register\" value=\"add\">"; + } if(isset($HTTP_GET_VARS["serviceid"])) { echo "<input type=\"submit\" name=\"register\" value=\"update\">"; diff --git a/frontends/php/srv_status.php b/frontends/php/srv_status.php index 8e18f4fd..8956480e 100644 --- a/frontends/php/srv_status.php +++ b/frontends/php/srv_status.php @@ -32,7 +32,7 @@ echo "<td width=10%><b>Status</b></td>"; echo "<td><b>Reason</b></td>"; echo "<td width=20%><b>SLA (last 7 days)</b></td>"; - echo "<td width=10% align=center><b>Planned/current<BR>SLA</b></td>"; + echo "<td width=10% align=center><b>Planned/current SLA</b></td>"; echo "<td width=5%><b>Graph</b></td>"; echo "</tr>"; echo "\n"; |
