diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-06-01 13:44:55 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-06-01 13:44:55 +0000 |
| commit | 6dd15b8a41d705ab1d0735a053a697f23b08d9b5 (patch) | |
| tree | 4591b95c92c34ae8251f700eb7e5b54b8d87c898 /frontends/php/include | |
| parent | 15eaca904b14e5396f766ef2d7979707e1090f7f (diff) | |
- developed aggrgated graphs (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@2935 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/classes/graph.inc.php | 304 | ||||
| -rw-r--r-- | frontends/php/include/defines.inc.php | 4 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 95 | ||||
| -rw-r--r-- | frontends/php/include/graphs.inc.php | 19 | ||||
| -rw-r--r-- | frontends/php/include/locales/en_gb.inc.php | 8 |
5 files changed, 237 insertions, 193 deletions
diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php index 8dd03a5c..8b39fc4c 100644 --- a/frontends/php/include/classes/graph.inc.php +++ b/frontends/php/include/classes/graph.inc.php @@ -90,57 +90,55 @@ function initColors() { -// 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["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 + $colors = array( /* Red, Green, Blue, Alpha */ + "Red" => array(255,0,0,50), + "Dark Red" => array(150,0,0,50), + "Green" => array(0,255,0,50), + "Dark Green" => array(0,150,0,50), + "Blue" => array(0,0,255,50), + "Dark Blue" => array(0,0,150,50), + "Yellow" => array(255,255,0,50), + "Dark Yellow" => array(150,150,0,50), + "Cyan" => array(0,255,255,50), + "Black" => array(0,0,0,50), + "Gray" => array(150,150,150,50), + "White" => array(255,255,255), + "Dark Red No Alpha" => array(150,0,0), + "Black No Alpha" => array(0,0,0), + + "HistoryMinMax" => array(90,150,185,50), + "HistoryMax" => array(255,100,100,50), + "HistoryMin" => array(50,255,50,50), + "HistoryAvg" => array(50,50,50,50), + + "ValueMinMax" => array(255,255,150,50), + "ValueMax" => array(255,180,180,50), + "ValueMin" => array(100,255,100,50), + + "Priority Disaster" => array(255,0,0), + "Priority Hight" => array(255,100,100), + "Priority Average" => array(221,120,120), + "Priority" => array(100,100,100), + "Not Work Period" => array(230,230,230), + ); + +// I should rename No Alpha to Alpha at some point to get rid of some confusion + foreach($colors as $name => $RGBA) { - $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); - + if(isset($RGBA[3]) && + function_exists("ImageColorExactAlpha") && + function_exists("ImageCreateTrueColor") && + @imagecreatetruecolor(1,1) + ) + { + $this->colors[$name] = ImageColorExactAlpha($this->im,$RGBA[0],$RGBA[1],$RGBA[2],$RGBA[3]); + } + else + { + $this->colors[$name] = ImageColorAllocate($this->im,$RGBA[0],$RGBA[1],$RGBA[2]); + } } - $this->colors["White"]= ImageColorAllocate($this->im,255,255,255); - $this->colors["Dark Red No Alpha"]= ImageColorAllocate($this->im,150,0,0); - $this->colors["Black No Alpha"]= ImageColorAllocate($this->im,0,0,0); - - $this->colors["Priority Disaster"]= ImageColorAllocate($this->im,255,0,0); - $this->colors["Priority Hight"]= ImageColorAllocate($this->im,255,100,100); - $this->colors["Priority Average"]= ImageColorAllocate($this->im,221,120,120); - $this->colors["Priority"]= ImageColorAllocate($this->im,100,100,100); -// $this->colors["Priority Disaster"]= $this->colors["Dark Red No Alpha"]; -// $this->colors["Priority Hight"]= $this->colors["Dark Red No Alpha"]; -// $this->colors["Priority Average"]= $this->colors["Dark Red No Alpha"]; -// $this->colors["Priority"]= $this->colors["Dark Red No Alpha"]; - - $this->colors["Not Work Period"]= ImageColorAllocate($this->im,230,230,230); } function Graph() @@ -182,7 +180,7 @@ $this->m_showTriggers = $value == 1 ? 1 : 0;; } - function addItem($itemid, $axis, $calc_fnc = CALC_FNC_AVG, $color=null, $drawtype=null) + function addItem($itemid, $axis, $calc_fnc = CALC_FNC_AVG, $color=null, $drawtype=null, $type=null, $periods_cnt=null) { $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_"]); @@ -193,6 +191,8 @@ $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; + $this->items[$this->num]["type"] = is_null($type) ? GRAPH_ITEM_SIMPLE : $type; + $this->items[$this->num]["periods_cnt"] = is_null($periods_cnt) ? 0 : $periods_cnt; if($axis==GRAPH_YAXIS_SIDE_LEFT) $this->yaxisleft=1; @@ -255,11 +255,11 @@ function getLastValue($num) { + $data = &$this->data[$this->items[$num]["itemid"]][$this->items[$num]["type"]]; for($i=899;$i>=0;$i--) { - if(isset($this->count[$num][$i])&&($this->count[$num][$i]>0)) + if(isset($data->count[$i]) && ($data->count[$i] > 0)) { - $data = &$this->data[$this->items[$num]["itemid"]]; switch($this->items[$num]["calc_fnc"]) { case CALC_FNC_MIN: return $data->min[$i]; @@ -537,7 +537,7 @@ default: $fnc_name = "avg"; } - $data = &$this->data[$this->items[$i]["itemid"]]; + $data = &$this->data[$this->items[$i]["itemid"]][$this->items[$i]["type"]]; if(isset($data->min)) { $str=sprintf("%s: %s (%s) [min:%s max:%s last:%s]", @@ -591,12 +591,15 @@ } } - function drawElement($item, $from, $to, $minX, $maxX, $minY, $maxY) + function drawElement( + &$data, $from, $to, + $minX, $maxX, $minY, $maxY, + $drawtype, $max_color, $avg_color, $min_color, $minmax_color, + $calc_fnc + ) { - $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; + $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; @@ -604,7 +607,7 @@ $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"]) + switch($calc_fnc) { case CALC_FNC_MAX: $y1 = $y1max; @@ -620,9 +623,9 @@ $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"]); + ImageFilledPolygon($this->im,$a,4,$minmax_color); + ImageLine($this->im,$x1,$y1max,$x2,$y2max,$max_color); + ImageLine($this->im,$x1,$y1min,$x2,$y2min,$min_color); /* don't use break, avg must be drawed in this statement */ // break; @@ -635,29 +638,27 @@ } - - if($this->items[$item]["drawtype"] == GRAPH_DRAW_TYPE_LINE) - { - ImageLine($this->im,$x1,$y1,$x2,$y2,$this->colors[$this->items[$item]["color"]]); - } - else if($this->items[$item]["drawtype"] == GRAPH_DRAW_TYPE_BOLDLINE) - { - ImageLine($this->im,$x1,$y1,$x2,$y2,$this->colors[$this->items[$item]["color"]]); - ImageLine($this->im,$x1,$y1+1,$x2,$y2+1,$this->colors[$this->items[$item]["color"]]); - } - else if($this->items[$item]["drawtype"] == GRAPH_DRAW_TYPE_FILL) + /* draw main line */ + switch($drawtype) { - $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; + case GRAPH_DRAW_TYPE_BOLDLINE: + ImageLine($this->im,$x1,$y1+1,$x2,$y2+1,$avg_color); + // break; /* don't use break, must be drawed line also */ + case GRAPH_DRAW_TYPE_LINE: + ImageLine($this->im,$x1,$y1,$x2,$y2,$avg_color); + break; + case 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; - ImageFilledPolygon($this->im,$a,4,$this->colors[$this->items[$item]["color"]]); - } - else if($this->items[$item]["drawtype"] == GRAPH_DRAW_TYPE_DOT) - { - ImageFilledRectangle($this->im,$x1-1,$y1-1,$x1+1,$y1+1,$this->colors[$this->items[$item]["color"]]); - ImageFilledRectangle($this->im,$x2-1,$y2-1,$x2+1,$y2+1,$this->colors[$this->items[$item]["color"]]); + ImageFilledPolygon($this->im,$a,4,$avg_color); + break; + case GRAPH_DRAW_TYPE_DOT: + ImageFilledRectangle($this->im,$x1-1,$y1-1,$x1+1,$y1+1,$avg_color); + ImageFilledRectangle($this->im,$x2-1,$y2-1,$x2+1,$y2+1,$avg_color); + break; } } // Calculation of maximum Y axis @@ -677,7 +678,7 @@ if($this->items[$i]["axisside"] != $side) continue; - $data = &$this->data[$this->items[$i]["itemid"]]; + $data = &$this->data[$this->items[$i]["itemid"]][$this->items[$i]["type"]]; switch($this->items[$i]["calc_fnc"]) { @@ -741,7 +742,7 @@ if($this->items[$i]["axisside"] != $side) continue; - $data = &$this->data[$this->items[$i]["itemid"]]; + $data = &$this->data[$this->items[$i]["itemid"]][$this->items[$i]["type"]]; switch($this->items[$i]["calc_fnc"]) { @@ -788,56 +789,62 @@ { global $DB_TYPE; + $this->data = array(); + $now = time(NULL); + if(isset($this->stime)) { -# $this->to_time=$this->stime+24*3600; -# $this->from_time=$this->stime; - $this->from_time=$this->stime; - $this->to_time=$this->stime+$this->period; + $this->from_time = $this->stime; + $this->to_time = $this->stime + $this->period; } else { - $this->to_time=$now-3600*$this->from; - $this->from_time=$this->to_time-$this->period; + $this->to_time = $now - 3600 * $this->from; + $this->from_time = $this->to_time - $this->period; } - - $p=$this->to_time-$this->from_time; - $z=$p-$this->from_time%$p; - $str=" "; - for($i=0;$i<$this->num;$i++) - { - $str=$str.$this->items[$i]["itemid"].","; - } - $str=substr($str,0,strlen($str)-1); - if($str=="") $str=-1; + $p = $this->to_time - $this->from_time; + $z = $p - $this->from_time % $p; - $sql_arr = array(); - if($this->period<=24*3600) + for($i=0; $i < $this->num; $i++) { - array_push($sql_arr, - "select itemid,round(900*(mod(clock+$z,$p))/($p),0) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max,max(clock) as clock from history where itemid in ($str) and clock>=".$this->from_time." and clock<=".$this->to_time." group by itemid,round(900*(mod(clock+$z,$p))/($p),0)", - "select itemid,round(900*(mod(clock+$z,$p))/($p),0) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max,max(clock) as clock from history_uint where itemid in ($str) and clock>=".$this->from_time." and clock<=".$this->to_time." group by itemid,round(900*(mod(clock+$z,$p))/($p),0)"); - } - else - { - array_push($sql_arr, - "select itemid,round(900*(mod(clock+$z,$p))/($p),0) as i,sum(num) as count,avg(value_avg) as avg,min(value_min) as min,max(value_max) as max,max(clock) as clock from trends where itemid in ($str) and clock>=".$this->from_time." and clock<=".$this->to_time." group by itemid,round(900*(mod(clock+$z,$p))/($p),0)"); - } -// echo "<br>",$sql,"<br>"; + $type = $this->items[$i]["type"]; + + if($type == GRAPH_ITEM_AGGREGATED) { + /* skip current period */ + $from_time = $this->from_time - $this->period * $this->items[$i]["periods_cnt"]; + $to_time = $this->from_time; + } else { + $from_time = $this->from_time; + $to_time = $this->to_time; + } + + $sql_arr = array(); + if($this->period <= 24*3600) + { + array_push($sql_arr, + "select itemid,round(900*(mod(clock+$z,$p))/($p),0) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max,max(clock) as clock from history where itemid=".$this->items[$i]["itemid"]." and clock>=".$from_time." and clock<=".$to_time." group by itemid,round(900*(mod(clock+$z,$p))/($p),0)", + "select itemid,round(900*(mod(clock+$z,$p))/($p),0) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max,max(clock) as clock from history_uint where itemid=".$this->items[$i]["itemid"]." and clock>=".$from_time." and clock<=".$to_time." group by itemid,round(900*(mod(clock+$z,$p))/($p),0)"); + } + else + { + array_push($sql_arr, + "select itemid,round(900*(mod(clock+$z,$p))/($p),0) as i,sum(num) as count,avg(value_avg) as avg,min(value_min) as min,max(value_max) as max,max(clock) as clock from trends where itemid=".$this->items[$i]["itemid"]." and clock>=".$from_time." and clock<=".$to_time." group by itemid,round(900*(mod(clock+$z,$p))/($p),0)"); + } - foreach($sql_arr as $sql) - { - $result=DBselect($sql); - while($row=DBfetch($result)) + foreach($sql_arr as $sql) { - $i=$row["i"]; - $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"]; + $result=DBselect($sql); + while($row=DBfetch($result)) + { + $idx=$row["i"]; + $this->data[$row["itemid"]][$type]->count[$idx] = $row["count"]; + $this->data[$row["itemid"]][$type]->min[$idx] = $row["min"]; + $this->data[$row["itemid"]][$type]->max[$idx] = $row["max"]; + $this->data[$row["itemid"]][$type]->avg[$idx] = $row["avg"]; + $this->data[$row["itemid"]][$type]->clock[$idx] = $row["clock"]; + } } } } @@ -936,21 +943,42 @@ $this->drawWorkPeriod(); $this->drawGrid(); -// ImageString($this->im, 0, 100, 100, $this->shiftXright, $this->colors["Red"]); -// ImageString($this->im, 0, 120, 120, $this->sizeX, $this->colors["Red"]); - - $maxX=900; - $minX=0; + $minX = 0; + $maxX = 900; // For each metric for($item=0;$item<$this->num;$item++) { $minY = $this->m_minY[$this->items[$item]["axisside"]]; $maxY = $this->m_maxY[$this->items[$item]["axisside"]]; - $data = &$this->data[$this->items[$item]["itemid"]]; + + $data = &$this->data[$this->items[$item]["itemid"]][$this->items[$item]["type"]]; + + if($this->items[$item]["type"] == GRAPH_ITEM_AGGREGATED) + { + $drawtype = GRAPH_DRAW_TYPE_LINE; + + $max_color = $this->colors["HistoryMax"]; + $avg_color = $this->colors["HistoryAvg"]; + $min_color = $this->colors["HistoryMin"]; + $minmax_color = $this->colors["HistoryMinMax"]; + + $calc_fnc = CALC_FNC_ALL; + } + else + { + $drawtype = $this->items[$item]["drawtype"]; + + $max_color = $this->colors["ValueMax"]; + $avg_color = $this->colors[$this->items[$item]["color"]]; + $min_color = $this->colors["ValueMin"]; + $minmax_color = $this->colors["ValueMinMax"]; + + $calc_fnc = $this->items[$item]["calc_fnc"]; + } // For each X - for($i = $minX; $i < $maxX; $i++) + for($i = $minX; $i <= $maxX; $i++) { if(isset($data->count[$i])&&($data->count[$i]>0)) { @@ -958,10 +986,9 @@ { if(isset($data->count[$j])&&($data->count[$j]>0)) { - // 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>"; + // Do not draw anything if difference between two points + // is more than 4*(item refresh period) + $diff = $data->clock[$i] - $data->clock[$j]; $cell = ($this->to_time - $this->from_time)/900; $delay = $this->items[$item]["delay"]; @@ -975,7 +1002,18 @@ if($diff >= 4*$delay) break; } - $this->drawElement($item, $i, $j, $maxX, $minX, $minY, $maxY); + $this->drawElement( + $data, + $i, $j, + $minX, $maxX, + $minY, $maxY, + $drawtype, + $max_color, + $avg_color, + $min_color, + $minmax_color, + $calc_fnc + ); break; } diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php index a78cf3eb..b3b0ac2c 100644 --- a/frontends/php/include/defines.inc.php +++ b/frontends/php/include/defines.inc.php @@ -224,6 +224,10 @@ define("CALC_FNC_MAX", 4); define("CALC_FNC_ALL", 7); + + define("GRAPH_ITEM_SIMPLE" , 0); + define("GRAPH_ITEM_AGGREGATED", 1); + /* 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 719b9a8d..9d9cdb1e 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,calc_fnc,show_history,history_len from graphs_items". + $result=DBselect("select itemid,color,drawtype,sortorder,yaxisside,calc_fnc,type,periods_cnt from graphs_items". " where gitemid=".$_REQUEST["gitemid"]); $row=DBfetch($result); @@ -836,8 +836,8 @@ $sortorder = $row["sortorder"]; $yaxisside = $row["yaxisside"]; $calc_fnc = $row["calc_fnc"]; - $show_history = $row["show_history"]; - $history_len = $row["history_len"]; + $type = $row["type"]; + $periods_cnt = $row["periods_cnt"]; } else { @@ -847,8 +847,8 @@ $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); + $type = get_request("type", 0); + $periods_cnt = get_request("periods_cnt", 5); } @@ -870,56 +870,59 @@ } $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)); - $cmbType->AddItem(2,get_drawtype_description(2)); - $cmbType->AddItem(3,get_drawtype_description(3)); + $cmbType = new CComboBox("type",$type,"submit()"); + $cmbType->AddItem(GRAPH_ITEM_SIMPLE, S_SIMPLE); + $cmbType->AddItem(GRAPH_ITEM_AGGREGATED, S_AGGREGATED); $frmGItem->AddRow(S_TYPE, $cmbType); + if($type == GRAPH_ITEM_AGGREGATED) + { + $frmGItem->AddRow(S_AGGREGATED_PERIODS_COUNT, new CTextBox("periods_cnt",$periods_cnt,15)); + + $frmGItem->AddVar("calc_fnc",$calc_fnc); + $frmGItem->AddVar("drawtype",$drawtype); + $frmGItem->AddVar("color",$color); + } + else + { + $frmGItem->AddVar("periods_cnt",$periods_cnt); + + $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)); + $cmbType->AddItem(2,get_drawtype_description(2)); + $cmbType->AddItem(3,get_drawtype_description(3)); + $frmGItem->AddRow(S_DRAW_STYLE, $cmbType); + + $cmbColor = new CComboBox("color",$color); + $cmbColor->AddItem("Black", S_BLACK); + $cmbColor->AddItem("Blue", S_BLUE); + $cmbColor->AddItem("Cyan", S_CYAN); + $cmbColor->AddItem("Dark Blue", S_DARK_BLUE); + $cmbColor->AddItem("Dark Green", S_DARK_GREEN); + $cmbColor->AddItem("Dark Red", S_DARK_RED); + $cmbColor->AddItem("Dark Yellow", S_DARK_YELLOW); + $cmbColor->AddItem("Green", S_GREEN); + $cmbColor->AddItem("Red", S_RED); + $cmbColor->AddItem("White", S_WHITE); + $cmbColor->AddItem("Yellow", S_YELLOW); + $frmGItem->AddRow(S_COLOR, $cmbColor); + } + $cmbYax = new CComboBox("yaxisside",$yaxisside); $cmbYax->AddItem(GRAPH_YAXIS_SIDE_RIGHT, S_RIGHT); $cmbYax->AddItem(GRAPH_YAXIS_SIDE_LEFT, S_LEFT); $frmGItem->AddRow(S_YAXIS_SIDE, $cmbYax); - $cmbColor = new CComboBox("color",$color); - $cmbColor->AddItem("Black", S_BLACK); - $cmbColor->AddItem("Blue", S_BLUE); - $cmbColor->AddItem("Cyan", S_CYAN); - $cmbColor->AddItem("Dark Blue", S_DARK_BLUE); - $cmbColor->AddItem("Dark Green", S_DARK_GREEN); - $cmbColor->AddItem("Dark Red", S_DARK_RED); - $cmbColor->AddItem("Dark Yellow", S_DARK_YELLOW); - $cmbColor->AddItem("Green", S_GREEN); - $cmbColor->AddItem("Red", S_RED); - $cmbColor->AddItem("White", S_WHITE); - $cmbColor->AddItem("Yellow", S_YELLOW); - $frmGItem->AddRow(S_COLOR, $cmbColor); - $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 b18000a7..5c0f09fa 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,$calc_fnc,$show_history,$history_len) + function add_item_to_graph($graphid,$itemid,$color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$type,$periods_cnt) { $result = DBexecute("insert into graphs_items". - " (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)"); + " (graphid,itemid,color,drawtype,sortorder,yaxisside,calc_fnc,type,periods_cnt)". + " values ($graphid,$itemid,".zbx_dbstr($color).",$drawtype,$sortorder,$yaxisside,$calc_fnc,$type,$periods_cnt)"); $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,$calc_fnc,$show_history,$history_len); + $color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$type,$periods_cnt); if(!$result) break; @@ -270,7 +270,7 @@ } // recursion $result = add_item_to_graph($child["graphid"],$db_item["itemid"], - $color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len); + $color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$type,$periods_cnt); if(!$result) break; } @@ -290,7 +290,7 @@ return $gitemid; } - function update_graph_item($gitemid,$itemid,$color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len) + function update_graph_item($gitemid,$itemid,$color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$type,$periods_cnt) { $gitem = get_graphitem_by_gitemid($gitemid); @@ -316,7 +316,7 @@ // recursion $result = update_graph_item($chd_gitem["gitemid"],$db_item["itemid"], - $color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$show_history,$history_len); + $color,$drawtype,$sortorder,$yaxisside,$calc_fnc,$type,$periods_cnt); if(!$result) return $reslut; break; @@ -324,7 +324,7 @@ } $result = DBexecute("update graphs_items set itemid=$itemid,color=".zbx_dbstr($color).",". "drawtype=$drawtype,sortorder=$sortorder,yaxisside=$yaxisside,calc_fnc=$calc_fnc". - ",show_history=".$show_history.",history_len=".$history_len. + ",type=".$type.",periods_cnt=".$periods_cnt. " where gitemid=$gitemid"); if($result) { @@ -495,7 +495,7 @@ $result = add_item_to_graph($dist_graphid,$host_itemid,$src_graphitem["color"], $src_graphitem["drawtype"],$src_graphitem["sortorder"], $src_graphitem["yaxisside"],$src_graphitem["calc_fnc"], - $src_graphitem["show_history"],$src_graphitem["history_len"]); + $src_graphitem["type"],$src_graphitem["periods_cnt"]); if(!$result) return $result; break; @@ -509,7 +509,6 @@ function navigation_bar_calc() { // $workingperiod = 3600; - if(!isset($_REQUEST["period"])) $_REQUEST["period"]=3600; if(!isset($_REQUEST["from"])) $_REQUEST["from"]=0; diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 0e997a32..500de240 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -306,10 +306,10 @@ "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", + "S_DRAW_STYLE"=> "Draw style", + "S_SIMPLE"=> "Simple", + "S_AGGREGATED"=> "Aggregated", + "S_AGGREGATED_PERIODS_COUNT"=> "Aggregated periods count", // graphs.php "S_CONFIGURATION_OF_GRAPHS"=> "Configuration of graphs", |
