diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-31 14:28:45 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-05-31 14:28:45 +0000 |
| commit | bfb41b23166d700a588f192bd0ad6e819595adba (patch) | |
| tree | 1c47a9bd2077047e9da96dfa5dfb3000a4d6c22c /frontends/php/include | |
| parent | 100ead984d87b8d482709fcea91e49d677dbb50b (diff) | |
| download | zabbix-bfb41b23166d700a588f192bd0ad6e819595adba.tar.gz zabbix-bfb41b23166d700a588f192bd0ad6e819595adba.tar.xz zabbix-bfb41b23166d700a588f192bd0ad6e819595adba.zip | |
- improved graphs, added selector of data calculation function (Eugene)
NOTE: don't finished historical graphs
git-svn-id: svn://svn.zabbix.com/trunk@2933 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/classes/cbutton.inc.php | 5 | ||||
| -rw-r--r-- | frontends/php/include/classes/graph.inc.php | 272 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 5 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 30 | ||||
| -rw-r--r-- | frontends/php/include/graphs.inc.php | 21 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 8 |
7 files changed, 229 insertions, 114 deletions
diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php index 0c33caaf..fd060619 100644 --- a/frontends/php/include/classes/cbutton.inc.php +++ b/frontends/php/include/classes/cbutton.inc.php @@ -44,8 +44,9 @@ } function SetAccessKey($value='B') { - if(!isset($this->options['title'])) - $this->SetTitle($this->options['value'].' [Alt+$value]'); + if(isset($value)) + if(!isset($this->options['title'])) + $this->SetTitle($this->options['value'].' [Alt+'.$value.']'); return $this->options['accessKey'] = $value; } diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php index efdcc0ee..8dd03a5c 100644 --- a/frontends/php/include/classes/graph.inc.php +++ b/frontends/php/include/classes/graph.inc.php @@ -45,10 +45,11 @@ var $m_minY; var $m_maxY; + var $data = array(); + // items[num].data.min[max|avg] var $items; // $idnum[$num] is itemid - var $itemids; var $min; var $max; var $avg; @@ -92,32 +93,38 @@ // I should rename No Alpha to Alpha at some point to get rid of some confusion if(function_exists("ImageColorExactAlpha")&&function_exists("ImageCreateTrueColor")&&@imagecreatetruecolor(1,1)) { - $this->colors["Red"]= ImageColorExactAlpha($this->im,255,0,0,50); - $this->colors["Dark Red"]= ImageColorExactAlpha($this->im,150,0,0,50); - $this->colors["Green"]= ImageColorExactAlpha($this->im,0,255,0,50); - $this->colors["Dark Green"]= ImageColorExactAlpha($this->im,0,150,0,50); - $this->colors["Blue"]= ImageColorExactAlpha($this->im,0,0,255,50); - $this->colors["Dark Blue"]= ImageColorExactAlpha($this->im,0,0,150,50); - $this->colors["Yellow"]= ImageColorExactAlpha($this->im,255,255,0,50); - $this->colors["Dark Yellow"]= ImageColorExactAlpha($this->im,150,150,0,50); - $this->colors["Cyan"]= ImageColorExactAlpha($this->im,0,255,255,50); - $this->colors["Black"]= ImageColorExactAlpha($this->im,0,0,0,50); - $this->colors["Gray"]= ImageColorExactAlpha($this->im,150,150,150,50); + $this->colors["Red"] = ImageColorExactAlpha($this->im,255,0,0,50); + $this->colors["Dark Red"] = ImageColorExactAlpha($this->im,150,0,0,50); + $this->colors["Green"] = ImageColorExactAlpha($this->im,0,255,0,50); + $this->colors["Dark Green"] = ImageColorExactAlpha($this->im,0,150,0,50); + $this->colors["Blue"] = ImageColorExactAlpha($this->im,0,0,255,50); + $this->colors["Dark Blue"] = ImageColorExactAlpha($this->im,0,0,150,50); + $this->colors["Yellow"] = ImageColorExactAlpha($this->im,255,255,0,50); + $this->colors["Dark Yellow"] = ImageColorExactAlpha($this->im,150,150,0,50); + $this->colors["Cyan"] = ImageColorExactAlpha($this->im,0,255,255,50); + $this->colors["Black"] = ImageColorExactAlpha($this->im,0,0,0,50); + $this->colors["Gray"] = ImageColorExactAlpha($this->im,150,150,150,50); + $this->colors["History"] = ImageColorExactAlpha($this->im,255,255,220,50); + $this->colors["HistoryMax"] = ImageColorExactAlpha($this->im,255,200,200,50); + $this->colors["HistoryMin"] = ImageColorExactAlpha($this->im,150,255,100,50); } else { - $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["Dark Blue"]=ImageColorAllocate($this->im,0,0,150); - $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["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["Dark Blue"] = ImageColorAllocate($this->im,0,0,150); + $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["History"] = ImageColorAllocate($this->im,150,150,50); + $this->colors["HistoryMax"] = ImageColorAllocate($this->im,150,50,50); + $this->colors["HistoryMin"] = ImageColorAllocate($this->im,50,150,50); } $this->colors["White"]= ImageColorAllocate($this->im,255,255,255); @@ -154,15 +161,6 @@ $this->m_showWorkPeriod = 1; $this->m_showTriggers = 1; - $this->count=array(); - $this->min=array(); - $this->max=array(); - $this->avg=array(); - $this->clock=array(); - - $this->itemids=array(); - - /* if($this->period<=3600) { $this->date_format="H:i"; @@ -184,16 +182,18 @@ $this->m_showTriggers = $value == 1 ? 1 : 0;; } - function addItem($itemid, $axis) + function addItem($itemid, $axis, $calc_fnc = CALC_FNC_AVG, $color=null, $drawtype=null) { - $this->items[$this->num]=get_item_by_itemid($itemid); + $this->items[$this->num] = get_item_by_itemid($itemid); $this->items[$this->num]["description"]=item_description($this->items[$this->num]["description"],$this->items[$this->num]["key_"]); $host=get_host_by_hostid($this->items[$this->num]["hostid"]); - $this->items[$this->num]["host"]=$host["host"]; - $this->itemids[$this->items[$this->num]["itemid"]]=$this->num; - $this->items[$this->num]["color"]="Dark Green"; - $this->items[$this->num]["drawtype"]=GRAPH_DRAW_TYPE_LINE; - $this->items[$this->num]["axisside"]=$axis; + + $this->items[$this->num]["host"] = $host["host"]; + $this->items[$this->num]["color"] = is_null($color) ? "Dark Green" : $color; + $this->items[$this->num]["drawtype"] = is_null($drawtype) ? GRAPH_DRAW_TYPE_LINE : $drawtype; + $this->items[$this->num]["axisside"] = $axis; + $this->items[$this->num]["calc_fnc"] = $calc_fnc; + if($axis==GRAPH_YAXIS_SIDE_LEFT) $this->yaxisleft=1; if($axis==GRAPH_YAXIS_SIDE_RIGHT) @@ -201,16 +201,6 @@ $this->num++; } - function SetColor($itemid,$color) - { - $this->items[$this->itemids[$itemid]]["color"]=$color; - } - - function setDrawtype($itemid,$drawtype) - { - $this->items[$this->itemids[$itemid]]["drawtype"]=$drawtype; - } - function setPeriod($period) { $this->period=$period; @@ -269,9 +259,18 @@ { if(isset($this->count[$num][$i])&&($this->count[$num][$i]>0)) { - return $this->avg[$num][$i]; + $data = &$this->data[$this->items[$num]["itemid"]]; + switch($this->items[$num]["calc_fnc"]) + { + case CALC_FNC_MIN: return $data->min[$i]; + case CALC_FNC_MAX: return $data->max[$i]; + case CALC_FNC_ALL: /* use avg */ + case CALC_FNC_AVG: + default: return $data->avg[$i]; + } } } + return 0; } function drawSmallRectangle() @@ -520,7 +519,7 @@ $max_desc_len=0; for($i=0;$i<$this->num;$i++) { - if(strlen($this->items[$i]["host"])>$max_host_len) $max_host_len=strlen($this->items[$i]["host"]); + if(strlen($this->items[$i]["host"])>$max_host_len) $max_host_len=strlen($this->items[$i]["host"]); if(strlen($this->items[$i]["description"])>$max_desc_len) $max_desc_len=strlen($this->items[$i]["description"]); } @@ -529,13 +528,24 @@ ImageFilledRectangle($this->im,$this->shiftXleft,$this->sizeY+$this->shiftY+62+12*$i,$this->shiftXleft+5,$this->sizeY+$this->shiftY+5+62+12*$i,$this->colors[$this->items[$i]["color"]]); ImageRectangle($this->im,$this->shiftXleft,$this->sizeY+$this->shiftY+62+12*$i,$this->shiftXleft+5,$this->sizeY+$this->shiftY+5+62+12*$i,$this->colors["Black No Alpha"]); - if(isset($this->min[$i])) + switch($this->items[$i]["calc_fnc"]) + { + case CALC_FNC_MIN: $fnc_name = "min"; break; + case CALC_FNC_MAX: $fnc_name = "max"; break; + case CALC_FNC_ALL: /* use avg */ + case CALC_FNC_AVG: + default: $fnc_name = "avg"; + } + + $data = &$this->data[$this->items[$i]["itemid"]]; + if(isset($data->min)) { - $str=sprintf("%s: %s [min:%s max:%s last:%s]", + $str=sprintf("%s: %s (%s) [min:%s max:%s last:%s]", str_pad($this->items[$i]["host"],$max_host_len," "), str_pad($this->items[$i]["description"],$max_desc_len," "), - convert_units(min($this->min[$i]),$this->items[$i]["units"]), - convert_units(max($this->max[$i]),$this->items[$i]["units"]), + $fnc_name, + convert_units(min($data->min),$this->items[$i]["units"]), + convert_units(max($data->max),$this->items[$i]["units"]), convert_units($this->getLastValue($i),$this->items[$i]["units"])); } else @@ -581,8 +591,51 @@ } } - function drawElement($item,$x1,$y1,$x2,$y2) + function drawElement($item, $from, $to, $minX, $maxX, $minY, $maxY) { + $data = &$this->data[$this->items[$item]["itemid"]]; + + $x1 = ($this->sizeX * ($from - $minX)/($maxX-$minX)) + $this->shiftXleft; + $x2 = ($this->sizeX * ($to - $minX)/($maxX-$minX)) + $this->shiftXleft-1; + + $y1min = $this->sizeY - ($this->sizeY*($data->min[$from]-$minY)/($maxY-$minY)) + $this->shiftY; + $y2min = $this->sizeY - ($this->sizeY*($data->min[$to]-$minY)/($maxY-$minY)) + $this->shiftY; + + $y1max = $this->sizeY - ($this->sizeY*($data->max[$from]-$minY)/($maxY-$minY)) + $this->shiftY; + $y2max = $this->sizeY - ($this->sizeY*($data->max[$to]-$minY)/($maxY-$minY)) + $this->shiftY; + + switch($this->items[$item]["calc_fnc"]) + { + case CALC_FNC_MAX: + $y1 = $y1max; + $y2 = $y2max; + break; + case CALC_FNC_MIN: + $y1 = $y1min; + $y2 = $y2min; + break; + case CALC_FNC_ALL: + $a[0] = $x1; $a[1] = $y1max; + $a[2] = $x1; $a[3] = $y1min; + $a[4] = $x2; $a[5] = $y2min; + $a[6] = $x2; $a[7] = $y2max; + + ImageFilledPolygon($this->im,$a,4,$this->colors["History"]); + ImageLine($this->im,$x1,$y1max,$x2,$y2max,$this->colors["HistoryMax"]); + ImageLine($this->im,$x1,$y1min,$x2,$y2min,$this->colors["HistoryMin"]); + + /* don't use break, avg must be drawed in this statement */ + // break; + case CALC_FNC_AVG: + /* don't use break, avg must be drawed in this statement */ + // break; + default: + $y1 = $this->sizeY - ($this->sizeY*($data->avg[$from]-$minY)/($maxY-$minY)) + $this->shiftY; + $y2 = $this->sizeY - ($this->sizeY*($data->avg[$to]-$minY)/($maxY-$minY)) + $this->shiftY; + + } + + if($this->items[$item]["drawtype"] == GRAPH_DRAW_TYPE_LINE) { ImageLine($this->im,$x1,$y1,$x2,$y2,$this->colors[$this->items[$item]["color"]]); @@ -594,14 +647,10 @@ } else if($this->items[$item]["drawtype"] == GRAPH_DRAW_TYPE_FILL) { - $a[0]=$x1; - $a[1]=$y1; - $a[2]=$x1; - $a[3]=$this->shiftY+$this->sizeY; - $a[4]=$x2; - $a[5]=$this->shiftY+$this->sizeY; - $a[6]=$x2; - $a[7]=$y2; + $a[0] = $x1; $a[1] = $y1; + $a[2] = $x1; $a[3] = $this->shiftY+$this->sizeY; + $a[4] = $x2; $a[5] = $this->shiftY+$this->sizeY; + $a[6] = $x2; $a[7] = $y2; ImageFilledPolygon($this->im,$a,4,$this->colors[$this->items[$item]["color"]]); } @@ -611,7 +660,6 @@ ImageFilledRectangle($this->im,$x2-1,$y2-1,$x2+1,$y2+1,$this->colors[$this->items[$item]["color"]]); } } - // Calculation of maximum Y axis function calculateMinY($side) { @@ -626,17 +674,30 @@ unset($minY); for($i=0;$i<$this->num;$i++) { - if($this->items[$i]["axisside"] != $side) continue; - if(!isset($minY)&&(isset($this->min[$i]))) + if($this->items[$i]["axisside"] != $side) + continue; + + $data = &$this->data[$this->items[$i]["itemid"]]; + + switch($this->items[$i]["calc_fnc"]) + { + case CALC_FNC_ALL: /* use min */ + case CALC_FNC_MIN: $val = &$data->min; break; + case CALC_FNC_MAX: $val = &$data->max; break; + case CALC_FNC_AVG: + default: $val = &$data->avg; + } + + if(!isset($minY)) { - if(count($this->max[$i])>0) + if(isset($val) && count($val) > 0) { - $minY=min($this->avg[$i]); + $minY = min($val); } } else { - $minY=@iif($minY>min($this->avg[$i]),min($this->avg[$i]),$minY); + $minY = min($minY, min($val)); } } @@ -673,20 +734,34 @@ } else { + unset($maxY); for($i=0;$i<$this->num;$i++) { - if($this->items[$i]["axisside"] != $side) continue; - if(!isset($maxY)&&(isset($this->max[$i]))) + if($this->items[$i]["axisside"] != $side) + continue; + + $data = &$this->data[$this->items[$i]["itemid"]]; + + switch($this->items[$i]["calc_fnc"]) + { + case CALC_FNC_ALL: /* use max */ + case CALC_FNC_MAX: $val = &$data->max; break; + case CALC_FNC_MIN: $val = &$data->min; break; + case CALC_FNC_AVG: + default: $val = &$data->avg; + } + + if(!isset($maxY)) { - if(count($this->max[$i])>0) + if(isset($val) && count($val) > 0) { - $maxY=max($this->avg[$i]); + $maxY = max($val); } } else { - $maxY=@iif($maxY<max($this->avg[$i]),max($this->avg[$i]),$maxY); + $maxY = max($maxY, max($val)); } } @@ -758,11 +833,11 @@ while($row=DBfetch($result)) { $i=$row["i"]; - $this->count[$this->itemids[$row["itemid"]]][$i]=$row["count"]; - $this->min[$this->itemids[$row["itemid"]]][$i]=$row["min"]; - $this->max[$this->itemids[$row["itemid"]]][$i]=$row["max"]; - $this->avg[$this->itemids[$row["itemid"]]][$i]=$row["avg"]; - $this->clock[$this->itemids[$row["itemid"]]][$i]=$row["clock"]; + $this->data[$row["itemid"]]->count[$i] = $row["count"]; + $this->data[$row["itemid"]]->min[$i] = $row["min"]; + $this->data[$row["itemid"]]->max[$i] = $row["max"]; + $this->data[$row["itemid"]]->avg[$i] = $row["avg"]; + $this->data[$row["itemid"]]->clock[$i] = $row["clock"]; } } } @@ -819,8 +894,8 @@ // $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40); -// Header( "Content-type: text/html"); -//* + Header( "Content-type: text/html"); +/* Header( "Content-type: image/png"); Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT"); /**/ @@ -872,41 +947,36 @@ { $minY = $this->m_minY[$this->items[$item]["axisside"]]; $maxY = $this->m_maxY[$this->items[$item]["axisside"]]; + $data = &$this->data[$this->items[$item]["itemid"]]; // For each X - for($i=0;$i<900;$i++) + for($i = $minX; $i < $maxX; $i++) { - if(isset($this->count[$item][$i])&&($this->count[$item][$i]>0)) + if(isset($data->count[$i])&&($data->count[$i]>0)) { for($j=$i-1;$j>=0;$j--) { - if(isset($this->count[$item][$j])&&($this->count[$item][$j]>0)) + if(isset($data->count[$j])&&($data->count[$j]>0)) { - $x1=$this->sizeX*($i-$minX)/($maxX-$minX); - $y1=$this->sizeY*($this->avg[$item][$i]-$minY)/($maxY-$minY); - $y1=$this->sizeY-$y1; - - $x2=$this->sizeX*($j-$minX)/($maxX-$minX); - $y2=$this->sizeY*($this->avg[$item][$j]-$minY)/($maxY-$minY); - $y2=$this->sizeY-$y2; - // Do not draw anything if difference between two points is more than 4*(item refresh period) // if($this->clock[$item][$i]-$this->clock[$item][$j]<4*$this->items[$item]["delay"]) // echo 8*($this->to_time-$this->from_time)/900,"<br>"; // echo $this->clock[$item][$i]-$this->clock[$item][$j],"<br>"; - $diff=$this->clock[$item][$i]-$this->clock[$item][$j]; - $cell=($this->to_time-$this->from_time)/900; - $delay=$this->items[$item]["delay"]; - if($cell>$delay) + $diff = $data->clock[$i] - $data->clock[$j]; + $cell = ($this->to_time - $this->from_time)/900; + $delay = $this->items[$item]["delay"]; + + if($cell > $delay) { - if($diff<16*$cell) - $this->drawElement($item, $x1+$this->shiftXleft,$y1+$this->shiftY,$x2+$this->shiftXleft+1,$y2+$this->shiftY); + if($diff >= 16*$cell) break; } else { - if($diff<4*$delay) - $this->drawElement($item, $x1+$this->shiftXleft,$y1+$this->shiftY,$x2+$this->shiftXleft+1,$y2+$this->shiftY); + if($diff >= 4*$delay) break; } + + $this->drawElement($item, $i, $j, $maxX, $minX, $minY, $maxY); + break; } } diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 6505e535..3d315f17 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -26,7 +26,7 @@ // $DB_TYPE ="POSTGRESQL"; $DB_TYPE ="MYSQL"; $DB_SERVER ="localhost"; - $DB_DATABASE ="zabbix"; + $DB_DATABASE ="osmiy"; $DB_USER ="root"; $DB_PASSWORD =""; // END OF DATABASE CONFIGURATION diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index 43569d3a..a78cf3eb 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -219,6 +219,11 @@ define("PROFILE_TYPE_INT", 2); define("PROFILE_TYPE_STR", 3); + define("CALC_FNC_MIN", 1); + define("CALC_FNC_AVG", 2); + define("CALC_FNC_MAX", 4); + define("CALC_FNC_ALL", 7); + /* Support for PHP5. PHP5 does not have $HTTP_..._VARS */ if (!function_exists('version_compare')) { diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index 2e9c5706..719b9a8d 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -822,7 +822,7 @@ if(isset($_REQUEST["gitemid"])) { - $result=DBselect("select itemid,color,drawtype,sortorder,yaxisside from graphs_items". + $result=DBselect("select itemid,color,drawtype,sortorder,yaxisside,calc_fnc,show_history,history_len from graphs_items". " where gitemid=".$_REQUEST["gitemid"]); $row=DBfetch($result); @@ -835,6 +835,9 @@ $drawtype = $row["drawtype"]; $sortorder = $row["sortorder"]; $yaxisside = $row["yaxisside"]; + $calc_fnc = $row["calc_fnc"]; + $show_history = $row["show_history"]; + $history_len = $row["history_len"]; } else { @@ -843,6 +846,9 @@ $drawtype = get_request("drawtype", 0); $sortorder = get_request("sortorder", 0); $yaxisside = get_request("yaxisside", 1); + $calc_fnc = get_request("calc_fnc", 2); + $show_history = get_request("show_history", 0); + $history_len = get_request("history_len", 5); } @@ -864,6 +870,13 @@ } $frmGItem->AddRow(S_PARAMETER, $cmbItems); + $cmbFnc = new CComboBox("calc_fnc",$calc_fnc); + $cmbFnc->AddItem(CALC_FNC_ALL, S_ALL_SMALL); + $cmbFnc->AddItem(CALC_FNC_MIN, S_MIN_SMALL); + $cmbFnc->AddItem(CALC_FNC_AVG, S_AVG_SMALL); + $cmbFnc->AddItem(CALC_FNC_MAX, S_MAX_SMALL); + $frmGItem->AddRow(S_FUNCTION, $cmbFnc); + $cmbType = new CComboBox("drawtype",$drawtype); $cmbType->AddItem(0,get_drawtype_description(0)); $cmbType->AddItem(1,get_drawtype_description(1)); @@ -892,6 +905,21 @@ $frmGItem->AddRow(S_SORT_ORDER_1_100, new CTextBox("sortorder",$sortorder,3)); + $cmbHist = new CComboBox("show_history",$show_history,"submit()"); + $cmbHist->AddItem(0,S_NO); + $cmbHist->AddItem(1,S_DAILY); + $cmbHist->AddItem(2,S_WEEKLY); + $cmbHist->AddItem(3,S_MONTHLY); + $frmGItem->AddRow(S_SHOW_HISTORY, $cmbHist); + + switch($show_history) + { + case 1: $frmGItem->AddRow(S_LAST_DAYS, new CTextBox("history_len",$history_len, 15)); break; + case 2: $frmGItem->AddRow(S_LAST_WEEKS, new CTextBox("history_len",$history_len, 15)); break; + case 3: $frmGItem->AddRow(S_LAST_MONTHS, new CTextBox("history_len",$history_len,15)); break; + default: $frmGItem->AddVar("history_len",$history_len); + } + $frmGItem->AddItemToBottomRow(new CButton("save",S_SAVE)); $frmGItem->AddItemToBottomRow(SPACE); if(isset($itemid)) diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php index a5c7f3aa..b18000a7 100644 --- a/frontends/php/include/graphs.inc.php +++ b/frontends/php/include/graphs.inc.php @@ -201,11 +201,11 @@ return 0; } - function add_item_to_graph($graphid,$itemid,$color,$drawtype,$sortorder,$yaxisside) + function add_item_to_graph($graphid,$itemid,$color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len) { $result = DBexecute("insert into graphs_items". - " (graphid,itemid,color,drawtype,sortorder,yaxisside)". - " values ($graphid,$itemid,".zbx_dbstr($color).",$drawtype,$sortorder,$yaxisside)"); + " (graphid,itemid,color,drawtype,sortorder,yaxisside,calc_fnc,show_history,history_len)". + " values ($graphid,$itemid,".zbx_dbstr($color).",$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len)"); $gitemid = DBinsert_id($result,"graphs_items","gitemid"); @@ -245,7 +245,7 @@ } // recursion $result = add_item_to_graph($new_graphid,$db_item["itemid"], - $color,$drawtype,$sortorder,$yaxisside); + $color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len); if(!$result) break; @@ -270,7 +270,7 @@ } // recursion $result = add_item_to_graph($child["graphid"],$db_item["itemid"], - $color,$drawtype,$sortorder,$yaxisside); + $color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len); if(!$result) break; } @@ -290,7 +290,7 @@ return $gitemid; } - function update_graph_item($gitemid,$itemid,$color,$drawtype,$sortorder,$yaxisside) + function update_graph_item($gitemid,$itemid,$color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len) { $gitem = get_graphitem_by_gitemid($gitemid); @@ -316,14 +316,16 @@ // recursion $result = update_graph_item($chd_gitem["gitemid"],$db_item["itemid"], - $color,$drawtype,$sortorder,$yaxisside); + $color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len); if(!$result) return $reslut; break; } } $result = DBexecute("update graphs_items set itemid=$itemid,color=".zbx_dbstr($color).",". - "drawtype=$drawtype,sortorder=$sortorder,yaxisside=$yaxisside where gitemid=$gitemid"); + "drawtype=$drawtype,sortorder=$sortorder,yaxisside=$yaxisside,calc_fnc=$calc_fnc". + ",show_history=".$show_history.",history_len=".$history_len. + " where gitemid=$gitemid"); if($result) { $host = get_host_by_itemid($item["itemid"]); @@ -492,7 +494,8 @@ $result = add_item_to_graph($dist_graphid,$host_itemid,$src_graphitem["color"], $src_graphitem["drawtype"],$src_graphitem["sortorder"], - $src_graphitem["yaxisside"]); + $src_graphitem["yaxisside"],$src_graphitem["calc_fnc"], + $src_graphitem["show_history"],$src_graphitem["history_len"]); if(!$result) return $result; break; diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index c30dc2cc..0e997a32 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -302,6 +302,14 @@ "S_SORT_ORDER_1_100"=> "Sort order (0->100)", "S_YAXIS_SIDE"=> "Y axis side", "S_LEFT"=> "Left", + "S_FUNCTION"=> "Function", + "S_MIN_SMALL"=> "min", + "S_AVG_SMALL"=> "avg", + "S_MAX_SMALL"=> "max", + "S_SHOW_HISTORY"=> "Show history", + "S_LAST_DAYS"=> "Last days", + "S_LAST_WEEKS"=> "Last weeks", + "S_LAST_MONTHS"=> "Last months", // graphs.php "S_CONFIGURATION_OF_GRAPHS"=> "Configuration of graphs", |
