summaryrefslogtreecommitdiffstats
path: root/frontends/php/chart3.php
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2002-08-04 16:53:24 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2002-08-04 16:53:24 +0000
commit2f691b3628c4589fe258def9564d78cd134d3ebb (patch)
tree278a676e3e5540977348c86b9d7a96ccc105902d /frontends/php/chart3.php
parent89d810024288866e72586c1774dec254db9aa884 (diff)
downloadzabbix-2f691b3628c4589fe258def9564d78cd134d3ebb.tar.gz
zabbix-2f691b3628c4589fe258def9564d78cd134d3ebb.tar.xz
zabbix-2f691b3628c4589fe258def9564d78cd134d3ebb.zip
- added upgrades/dbpatches/1.0beta4_to_1.0beta5/ with patches (Alexei)
- added support for disktotal[*] (Alexei) - added support for inodetotal[*] (Alexei) - added support for *,/,+, and - in trigger expressions (Alexei) - removed frontends/php/chart4.php (Alexei) - update item status to UNSUPPORTED in case if SNMP support was not included into zabbix_suckerd (Alexei) - added mysql_init() to DBconnect() (Alexei) - fixed Next100 and Prev100 for case if some hosts are hidden (Alexei) - added select for latest values (Alexei) - delete related services if trigger is deleted (Alexei) - fixed problem with substitution of macros for messages (Alexei) - eliminated DBis_empty() by replacing to DBnum_rows() (Alexei) - MAX_STRING_LEN increased to 4096 (Alexei) - fixed zabbix_log(). Possible coredump if data contains %s, etc (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@445 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/chart3.php')
-rw-r--r--frontends/php/chart3.php87
1 files changed, 66 insertions, 21 deletions
diff --git a/frontends/php/chart3.php b/frontends/php/chart3.php
index d7d6c1ab..c77d32fa 100644
--- a/frontends/php/chart3.php
+++ b/frontends/php/chart3.php
@@ -7,6 +7,8 @@
# type
# trendavg
+ $start_time=time(NULL);
+
if(!isset($type))
{
$type="week";
@@ -22,7 +24,7 @@
}
else if($type == "year")
{
- $period=365*30*24*3600;
+ $period=365*24*3600;
}
else
{
@@ -37,8 +39,6 @@
$shiftYup=13;
$shiftYdown=7+15*2;
- $nodata=1;
-
// Header( "Content-type: text/html");
Header( "Content-type: image/png");
@@ -51,11 +51,14 @@
$green=ImageColorAllocate($im,0,255,0);
$darkgreen=ImageColorAllocate($im,0,150,0);
$blue=ImageColorAllocate($im,0,0,255);
+ $darkblue=ImageColorAllocate($im,0,0,150);
$yellow=ImageColorAllocate($im,255,255,0);
+ $darkyellow=ImageColorAllocate($im,150,150,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);
+ $bg=ImageColorAllocate($im,6+6*16,7+7*16,8+8*16);
$x=imagesx($im);
$y=imagesy($im);
@@ -65,21 +68,46 @@
$now = time(NULL);
$to_time=$now;
- $from_time=$to_time-14*24*3600;
+ $from_time=$to_time-$period;
+ $from_time_now=$to_time-24*3600;
$count=array();
$min=array();
$max=array();
$avg=array();
+if($DB_TYPE=="MYSQL")
+{
+ $sql="select round(900*((clock+3*3600)%(24*3600))/(24*3600)) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max from history where itemid=$itemid and clock>$from_time and clock<$to_time group by round(900*((clock+3*3600)%(24*3600))/(24*3600))";
+// echo $sql."<br>";
+ $result=DBselect($sql);
+ while($row=DBfetch($result))
+ {
+ $i=$row["i"];
+
+ $max[$i]=$row["max"];
+ $min[$i]=$row["min"];
+ $avg[$i]=$row["avg"];
+ $count[$i]=$row["count"];
+ }
+
+ $count_now=array();
+ $avg_now=array();
+ $result=DBselect("select round(900*((clock+3*3600)%(24*3600))/(24*3600)) as i,count(*) as count,avg(value) as avg,min(value) as min,max(value) as max from history where itemid=$itemid and clock>$from_time_now and clock<$to_time group by round(900*((clock+3*3600)%(24*3600))/(24*3600))");
+ while($row=DBfetch($result))
+ {
+ $i=$row["i"];
+ $avg_now[$i]=$row["avg"];
+ $count_now[$i]=$row["count"];
+ }
+}
+else
+{
$result=DBselect("select clock,value from history where itemid=$itemid and clock>$from_time and clock<$to_time");
while($row=DBfetch($result))
{
$value=$row["value"];
$i=intval( 900*(($row["clock"]+3*3600)%(24*3600))/(24*3600));
-// $value=$i;
-// if($i==0) echo "B:",date("dS of F Y h:i:s A",$row["clock"]),"<br>";
-// if($i==899) echo "E:",date("dS of F Y h:i:s A",$row["clock"]),"<br>";
if( (!isset($max[$i])) || ($max[$i]<$value))
{
@@ -102,19 +130,15 @@
{
$avg[$i]=$value;
}
- $nodata=0;
}
$count_now=array();
$avg_now=array();
- $to_time=$now;
- $from_time=$to_time-$period;
- $result=DBselect("select clock,value from history where itemid=$itemid and clock>$from_time and clock<$to_time");
+ $result=DBselect("select clock,value from history where itemid=$itemid and clock>$from_time_now and clock<$to_time");
while($row=DBfetch($result))
{
$value=$row["value"];
$i=intval( 900*(($row["clock"]+3*3600)%(24*3600))/(24*3600));
-// $i=intval( 900*(($to_time-$row["clock"]+75600)%(24*3600))/(24*3600));
// echo (mktime(0, 0, 0, 07, 27,2002)-75600)%(24*3600),"<br>";
if(isset($count_now[$i]))
@@ -134,6 +158,7 @@
$avg_now[$i]=$value;
}
}
+}
for($i=0;$i<=$sizeY;$i+=$sizeY/5)
{
@@ -143,19 +168,23 @@
for($i=0;$i<=$sizeX;$i+=$sizeX/24)
{
ImageDashedLine($im,$i+$shiftX,$shiftYup,$i+$shiftX,$sizeY+$shiftYup,$gray);
- if($nodata == 0)
- {
- ImageString($im, 1,$i+$shiftX-11, $sizeY+$shiftYup+5, date("H:i",-3*3600+24*3600*$i/900) , $black);
- }
+ ImageString($im, 1,$i+$shiftX-11, $sizeY+$shiftYup+5, date("H:i",-3*3600+24*3600*$i/900) , $black);
}
unset($maxY);
unset($minY);
- if($nodata == 0)
+ $maxY=max($avg);
+ $tmp=max($avg_now);
+ if($tmp>$maxY)
+ {
+ $maxY=$tmp;
+ }
+ $minY=min($avg);
+ $tmp=min($avg_now);
+ if($tmp<$minY)
{
- $maxY=max($avg);
- $minY=min($avg);
+ $minY=$tmp;
}
$maxX=900;
@@ -171,6 +200,18 @@
{
$x1=$sizeX*($i-$minX)/($maxX-$minX);
$y1=$sizeY*($max[$i]-$minY)/($maxY-$minY);
+ $x2=$sizeX*($i-$minX)/($maxX-$minX);
+ $y2=$sizeY*($min[$i]-$minY)/($maxY-$minY);
+ $y1=$sizeY-$y1;
+ $y2=$sizeY-$y2;
+
+ ImageLine($im,$x1+$shiftX,$y1+$shiftYup,$x2+$shiftX,$y2+$shiftYup,$bg);
+ }*/
+
+/* if(!isset($trendavg))
+ {
+ $x1=$sizeX*($i-$minX)/($maxX-$minX);
+ $y1=$sizeY*($max[$i]-$minY)/($maxY-$minY);
$x2=$x1;
$y2=0;
$y1=$sizeY-$y1;
@@ -214,6 +255,7 @@
$y2=$sizeY-$y2;
ImageLine($im,$x1+$shiftX,$y1+$shiftYup,$x2+$shiftX,$y2+$shiftYup,$darkred);
+// ImageLine($im,$x1+$shiftX-1,$y1+$shiftYup,$x2+$shiftX-1,$y2+$shiftYup,$darkred);
}
}
@@ -260,12 +302,15 @@
ImageFilledRectangle($im,$shiftX,$sizeY+$shiftYup+19+15*1,$shiftX+5,$sizeY+$shiftYup+15+9+15*1,$darkred);
ImageRectangle($im,$shiftX,$sizeY+$shiftYup+19+15*1,$shiftX+5,$sizeY+$shiftYup+15+9+15*1,$black);
- ImageString($im, 2,$shiftX+9,$sizeY+$shiftYup+15*1+15, "Average today", $black);
+ ImageString($im, 2,$shiftX+9,$sizeY+$shiftYup+15*1+15, "Average for last 24 hours", $black);
// ImageString($im, 1,$shiftX, $sizeY+$shiftY+15, "AVG (LAST WEEK)" , $darkgreen);
// ImageString($im, 1,$shiftX+80, $sizeY+$shiftY+15, "AVG (TODAY)" , $darkred);
- ImageStringUp($im,0,2*$shiftX+$sizeX+40,$sizeY+$shiftYup+$shiftYdown, "http://zabbix.sourceforge.net", $gray);
+ ImageStringUp($im,0,imagesx($im)-10,imagesy($im)-50, "http://zabbix.sourceforge.net", $gray);
+
+ $end_time=time(NULL);
+ ImageString($im, 0,imagesx($im)-100,imagesy($im)-12,"Generated in ".($end_time-$start_time)." sec", $gray);
ImagePng($im);
ImageDestroy($im);