summaryrefslogtreecommitdiffstats
path: root/frontends/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
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')
-rw-r--r--frontends/php/alerts.php6
-rw-r--r--frontends/php/chart.php16
-rw-r--r--frontends/php/chart2.php21
-rw-r--r--frontends/php/chart3.php87
-rw-r--r--frontends/php/chart4.php227
-rw-r--r--frontends/php/chart_diff.php13
-rw-r--r--frontends/php/compare.php2
-rw-r--r--frontends/php/include/config.inc.php25
-rw-r--r--frontends/php/latest.php75
-rw-r--r--frontends/php/latestalarms.php6
-rw-r--r--frontends/php/map.php2
-rw-r--r--frontends/php/report2.php1
-rw-r--r--frontends/php/services.php4
-rw-r--r--frontends/php/tr_status.php2
-rw-r--r--frontends/php/trend.php29
15 files changed, 227 insertions, 289 deletions
diff --git a/frontends/php/alerts.php b/frontends/php/alerts.php
index 5557e3cb..983839c7 100644
--- a/frontends/php/alerts.php
+++ b/frontends/php/alerts.php
@@ -41,11 +41,11 @@
<?
if(!isset($start))
{
- $sql="select a.alertid,a.clock,a.type,a.sendto,a.subject,a.message,ac.triggerid,a.status,a.retries from alerts a,actions ac where a.actionid=ac.actionid order by a.clock desc limit 100";
+ $sql="select a.alertid,a.clock,a.type,a.sendto,a.subject,a.message,ac.triggerid,a.status,a.retries from alerts a,actions ac where a.actionid=ac.actionid order by a.clock desc limit 1000";
}
else
{
- $sql="select a.alertid,a.clock,a.type,a.sendto,a.subject,a.message,ac.triggerid,a.status,a.retries from alerts a,actions ac where a.actionid=ac.actionid order by a.clock desc limit ".($start+100);
+ $sql="select a.alertid,a.clock,a.type,a.sendto,a.subject,a.message,ac.triggerid,a.status,a.retries from alerts a,actions ac where a.actionid=ac.actionid order by a.clock desc limit ".($start+1000);
}
$result=DBselect($sql);
@@ -76,6 +76,8 @@
if($col++%2==0) { echo "<tr bgcolor=#DDDDDD>"; }
else { echo "<tr bgcolor=#EEEEEE>"; }
+ if($col>100) break;
+
echo "<TD><a href=\"alarms.php?triggerid=".$row["triggerid"]."\">".date("Y.M.d H:i:s",$row["clock"])."</a></TD>";
if($row["type"]=="EMAIL")
{
diff --git a/frontends/php/chart.php b/frontends/php/chart.php
index ec50e7a6..d99f2d20 100644
--- a/frontends/php/chart.php
+++ b/frontends/php/chart.php
@@ -21,7 +21,7 @@
$sizeY=200;
$shiftX=10;
- $shiftY=13;
+ $shiftY=17;
$nodata=1;
@@ -59,8 +59,11 @@
}
$item=get_item_by_itemid($itemid);
$host=get_host_by_hostid($item["hostid"]);
- ImageString($im, 4,$sizeX/2-50,-1, $host["host"].":".$item["description"] , $darkred);
-// ImageStringUp($im,1,0,$sizeY, $host["host"].":".$item["description"], $darkred);
+
+ $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;
@@ -103,12 +106,7 @@
$y1=$sizeY-$y1;
$y2=$sizeY-$y2;
-// echo $x1," - ",$x2," - ",$y1," - ",$y2,"<Br>";
ImageLine($im,$x1+$shiftX,$y1+$shiftY,$x2+$shiftX,$y2+$shiftY,$darkgreen);
-// ImageSetPixel($im,$x2+$shiftX,$y2+$shiftY,$darkred);
-// ImageSetPixel($im,$x2+$shiftX+1,$y2+$shiftY,$darkred);
-// ImageSetPixel($im,$x2+$shiftX-1,$y2+$shiftY,$darkred);
-// ImageSetPixel($im,$x2+$shiftX,$y2+$shiftY+1,$darkred);
// ImageSetPixel($im,$x2+$shiftX,$y2+$shiftY-1,$darkred);
}
}
@@ -139,7 +137,7 @@
ImageString($im, 2,$sizeX/2-50, $sizeY+$shiftY+3, "NO DATA FOUND FOR THIS PERIOD" , $darkred);
}
- ImageStringUp($im,0,2*$shiftX+$sizeX+40,$sizeY+2*$shiftY, "http://zabbix.sourceforge.net", $gray);
+ ImageStringUp($im,0,imagesx($im)-10,imagesy($im)-50, "http://zabbix.sourceforge.net", $gray);
ImagePng($im);
ImageDestroy($im);
diff --git a/frontends/php/chart2.php b/frontends/php/chart2.php
index b4b2b387..af5488bd 100644
--- a/frontends/php/chart2.php
+++ b/frontends/php/chart2.php
@@ -5,8 +5,10 @@
# graphid
-#? period
-#? from
+# period
+# from
+
+ $start_time=time(NULL);
if(!isset($period))
{
@@ -29,14 +31,14 @@
$nodata=1;
- Header( "Content-type: text/html");
-// Header( "Content-type: image/png");
+// Header( "Content-type: text/html");
+ Header( "Content-type: image/png");
Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT");
$result2=DBselect("select gi.itemid,i.description,gi.color,h.host from graphs_items gi,items i,hosts h where gi.itemid=i.itemid and gi.graphid=$graphid and i.hostid=h.hostid order by gi.gitemid");
$shiftX=10;
- $shiftYup=13;
+ $shiftYup=17;
$shiftYdown=7+15*DBnum_rows($result2);
$im = imagecreate($sizeX+$shiftX+61,$sizeY+$shiftYup+$shiftYdown+10+50);
@@ -81,7 +83,9 @@
}
$graph=get_graph_by_graphid($graphid);
- ImageString($im, 4,$sizeX/2-50,-1, $graph["name"] , $darkred);
+ $str=$graph["name"];
+ $x=imagesx($im)/2-ImageFontWidth(4)*strlen($str)/2;
+ ImageString($im, 4,$x,1, $str , $darkred);
$from_time = time(NULL)-$period-3600*$from;
$to_time = time(NULL)-3600*$from;
@@ -180,7 +184,10 @@
}
# ImageString($im,0,$shiftX+$sizeX-85,$sizeY+$shiftYup+25, "http://zabbix.sourceforge.net", $gray);
- ImageStringUp($im,0,2*$shiftX+$sizeX+40,$sizeY+$shiftYdown+$shiftYup, "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);
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);
diff --git a/frontends/php/chart4.php b/frontends/php/chart4.php
deleted file mode 100644
index 4e4fba33..00000000
--- a/frontends/php/chart4.php
+++ /dev/null
@@ -1,227 +0,0 @@
-<?
- include "include/config.inc.php";
-
-# PARAMETERS:
-
-# itemid
-# type
-# trendavg
-
- if(!isset($type))
- {
- $type="week";
- }
-
- if($type == "month")
- {
- $period=24*30*2400;
- }
- else if($type == "week")
- {
- $period=7*24*3600;
- }
- else if($type == "year")
- {
- $period=12*30*24*3600;
- }
- else
- {
- $type="week";
- $period=7*24*3600;
- }
-
- $sizeX=900;
- $sizeY=200;
-
- $shiftX=12;
- $shiftY=15;
-
- $nodata=1;
-
-
-// Header( "Content-type: text/html");
- Header( "Content-type: image/png");
- Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT");
-
- $im = imagecreate($sizeX+$shiftX+61,$sizeY+2*$shiftY+10);
-
- $red=ImageColorAllocate($im,255,0,0);
- $darkred=ImageColorAllocate($im,150,0,0);
- $green=ImageColorAllocate($im,0,255,0);
- $darkgreen=ImageColorAllocate($im,0,150,0);
- $blue=ImageColorAllocate($im,0,0,255);
- $darkblue=ImageColorAllocate($im,0,0,150);
- $yellow=ImageColorAllocate($im,255,255,0);
- $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);
-
- $x=imagesx($im);
- $y=imagesy($im);
-
- ImageFilledRectangle($im,0,0,$sizeX+$shiftX+61,$sizeY+2*$shiftY+10,$white);
- ImageRectangle($im,0,0,$x-1,$y-1,$black);
-
- $now = time(NULL);
- $to_time=$now;
- $from_time=$to_time-$period*24*3600;
-
- $count=array();
- $min=array();
- $max=array();
- $avg=array();
-
-// $result=DBselect("select clock,value from history where itemid=$itemid and clock>$from_time and clock<$to_time");
- $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 and clock<$to_time group by round(900*((clock+3*3600)%(24*3600))/(24*3600))");
- while($row=DBfetch($result))
- {
- $i=$row["i"];
-
- $max[$i]=$row["max"];
- $min[$i]=$row["min"];
- $avg[$i]=$row["avg"];
- $count[$i]=$row["count"];
- $nodata=0;
-
-// echo $i," ",$avg[$i],"<br>";
- }
-
- $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 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))");
- while($row=DBfetch($result))
- {
- $i=$row["i"];
- $avg_now[$i]=$row["avg"];
- $count_now[$i]=$row["count"];
- }
-
- for($i=0;$i<=$sizeY;$i+=50)
- {
- ImageDashedLine($im,$shiftX,$i+$shiftY,$sizeX+$shiftX,$i+$shiftY,$gray);
- }
-
- for($i=0;$i<=$sizeX;$i+=50)
- {
- ImageDashedLine($im,$i+$shiftX,$shiftY,$i+$shiftX,$sizeY+$shiftY,$gray);
- if($nodata == 0)
- {
- ImageString($im, 1,$i+$shiftX-11, $sizeY+$shiftY+5, date($label_format,-3*3600+24*3600*$i/900) , $black);
- }
- }
-
- unset($maxY);
- unset($minY);
-
- if($nodata == 0)
- {
- if(isset($trendavg))
- {
- $maxY=max($avg);
- $minY=min($avg);
- }
- else
- {
- $maxY=max($max);
- $minY=min($min);
- }
- }
-
- $maxX=900;
- $minX=0;
-
- if(isset($minY)&&($maxY)&&($minX!=$maxX)&&($minY!=$maxY))
- {
- for($i=0;$i<900;$i++)
- {
- if($count[$i]>0)
- {
- if(!isset($trendavg))
- {
- $x1=$sizeX*($i-$minX)/($maxX-$minX);
- $y1=$sizeY*($max[$i]-$minY)/($maxY-$minY);
- $x2=$x1;
- $y2=0;
- $y1=$sizeY-$y1;
- $y2=$sizeY-$y2;
-
-// ImageLine($im,$x1+$shiftX,$y1+$shiftY,$x2+$shiftX,$y2+$shiftY,$darkred);
- }
-
- $x1=$sizeX*($i-$minX)/($maxX-$minX);
- $y1=$sizeY*($avg[$i]-$minY)/($maxY-$minY);
- $x2=$x1;
- $y2=0;
- $y1=$sizeY-$y1;
- $y2=$sizeY-$y2;
-
- ImageLine($im,$x1+$shiftX,$y1+$shiftY,$x2+$shiftX,$y2+$shiftY,$darkgreen);
-
- if(!isset($trendavg))
- {
- $x1=$sizeX*($i-$minX)/($maxX-$minX);
- $y1=$sizeY*($min[$i]-$minY)/($maxY-$minY);
- $x2=$x1;
- $y2=0;
- $y1=$sizeY-$y1;
- $y2=$sizeY-$y2;
-
-// ImageLine($im,$x1+$shiftX,$y1+$shiftY,$x2+$shiftX,$y2+$shiftY,$darkgreen);
- }
- }
- if(($count_now[$i]>0)&&($count_now[$i-1]>0))
- {
- if(!isset($trendavg)&&($i>0))
- {
- $x1=$sizeX*($i-$minX)/($maxX-$minX);
- $y1=$sizeY*($avg_now[$i]-$minY)/($maxY-$minY);
- $x2=$sizeX*($i-$minX-1)/($maxX-$minX);
- $y2=$sizeY*($avg_now[$i-1]-$minY)/($maxY-$minY);
-// $x2=$x1;
-// $y2=0;
- $y1=$sizeY-$y1;
- $y2=$sizeY-$y2;
-
- ImageLine($im,$x1+$shiftX,$y1+$shiftY,$x2+$shiftX,$y2+$shiftY,$darkred);
- }
- }
-
-
-# ImageStringUp($im, 1, $x1+10, $sizeY+$shiftY+15, $i , $red);
- }
- }
- else
- {
-// ImageLine($im,$shiftX,$shiftY+$sizeY/2,$sizeX+$shiftX,$shiftY+$sizeY/2,$green);
- }
-
- if($nodata == 0)
- {
- for($i=0;$i<=$sizeY;$i+=50)
- {
- ImageString($im, 1, $sizeX+5+$shiftX, $sizeY-$i-4+$shiftY, $i*($maxY-$minY)/$sizeY+$minY , $darkred);
- }
-
-// 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($im, 2,$sizeX/2 -50, $sizeY+$shiftY+3, "NO DATA FOR THIS PERIOD" , $red);
- }
-
- ImageString($im, 1,$shiftX, $sizeY+$shiftY+15, "AVG (LAST $type)" , $darkgreen);
- ImageString($im, 1,$shiftX+80, $sizeY+$shiftY+15, "AVG (TODAY)" , $darkred);
-
- ImageStringUp($im,0,2*$shiftX+$sizeX+40,$sizeY+2*$shiftY, "http://zabbix.sourceforge.net", $gray);
-
- ImagePng($im);
- ImageDestroy($im);
-?>
diff --git a/frontends/php/chart_diff.php b/frontends/php/chart_diff.php
index d261b4ac..6052d4b7 100644
--- a/frontends/php/chart_diff.php
+++ b/frontends/php/chart_diff.php
@@ -21,7 +21,7 @@
$sizeY=200;
$shiftX=10;
- $shiftY=13;
+ $shiftY=17;
$nodata=1;
@@ -51,15 +51,18 @@
for($i=0;$i<=$sizeY;$i+=$sizeY/5)
{
- ImageDashedLine($im,$shiftX,$i+$shiftY,$sizeX+$shiftX,$i+$shiftY,$black);
+ 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,$black);
+ ImageDashedLine($im,$i+$shiftX,$shiftY,$i+$shiftX,$sizeY+$shiftY,$gray);
}
$item=get_item_by_itemid($itemid);
$host=get_host_by_hostid($item["hostid"]);
- ImageString($im, 4,$sizeX/2-50,-1, $host["host"].":".$item["description"]." (diff)" , $darkred);
+
+ $str=$host["host"].":".$item["description"]." (diff)";
+ $x=imagesx($im)/2-ImageFontWidth(4)*strlen($str)/2;
+ ImageString($im, 4,$x,1, $str , $darkred);
$from_time = time(NULL)-$period-3600*$from;
$to_time = time(NULL)-3600*$from;
@@ -158,7 +161,7 @@
ImageString($im, 2,$sizeX/2-50, $sizeY+$shiftY+3, "NO DATA FOUND FOR THIS PERIOD" , $darkred);
}
- ImageStringUp($im,0,2*$shiftX+$sizeX+40,$sizeY+2*$shiftY, "http://zabbix.sourceforge.net", $gray);
+ ImageStringUp($im,0,imagesx($im)-10,imagesy($im)-50, "http://zabbix.sourceforge.net", $gray);
ImagePng($im);
ImageDestroy($im);
diff --git a/frontends/php/compare.php b/frontends/php/compare.php
index 89c1a8d1..29fb403a 100644
--- a/frontends/php/compare.php
+++ b/frontends/php/compare.php
@@ -2,7 +2,7 @@
include "include/config.inc.php";
$page["title"] = "Latest values";
$page["file"] = "latest.php";
- show_header($page["title"],0,0);
+ show_header($page["title"],300,0);
?>
<?
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 765084b7..8bfc4dad 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -433,7 +433,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
// Replace all <float> <sign> <float> with 0
// echo "Expression:$expression<br>";
$arr="";
- if (eregi('^((.)*)([0-9\.]+)([\&\|\>\<\=]{1})([0-9\.]+)((.)*)$', $expression, &$arr))
+ if (eregi('^((.)*)([0-9\.]+)([\&\|\>\<\=\+\-\*\/]{1})([0-9\.]+)((.)*)$', $expression, &$arr))
{
// echo "OK<br>";
// for($i=0;$i<50;$i++)
@@ -451,7 +451,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
$ERROR_MSG="[".$arr[5]."] is not a float";
return -1;
}
- $expression=$arr[1]."0".$arr[6];
+ $expression=$arr[1]."(0)".$arr[6];
}
else
{
@@ -460,7 +460,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
// Replace all (float) with 0
-// echo "Expression2:$expression<br>";
+// echo "Expression2:[$expression]<br>";
$arr="";
if (eregi('^((.)*)(\(([0-9\.]+)\))((.)*)$', $expression, &$arr))
{
@@ -1623,7 +1623,19 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
}
$sql="delete from functions where itemid=$itemid";
return DBexecute($sql);
+ }
+ # Delete Service definitions by triggerid
+
+ function delete_services_by_triggerid($triggerid)
+ {
+ $sql="select serviceid from services where triggerid=$triggerid";
+ $result=DBselect($sql);
+ for($i=0;$i<DBnum_rows($result);$i++)
+ {
+ delete_service(DBget_field($result,$i,0));
+ }
+ return TRUE;
}
# Delete Item definition
@@ -1741,6 +1753,11 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
{
return $result;
}
+ $result=delete_services_by_triggerid($triggerid);
+ if(!$result)
+ {
+ return $result;
+ }
$sql="delete from triggers where triggerid=$triggerid";
return DBexecute($sql);
@@ -1832,7 +1849,7 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
$delay=DBget_field($result,$i,3);
$value_type=DBget_field($result,$i,4);
- $itemid=add_item($description,$key,$hostid,$delay,30*24*3600,0,0,"","",$value_type,'');
+ $itemid=add_item($description,$key,$hostid,$delay,30,0,0,"","",$value_type,'');
$result2=DBselect("select triggertemplateid,description,expression from triggers_template where itemtemplateid=$itemtemplateid");
for($j=0;$j<DBnum_rows($result2);$j++)
diff --git a/frontends/php/latest.php b/frontends/php/latest.php
index 1031e392..b38454f7 100644
--- a/frontends/php/latest.php
+++ b/frontends/php/latest.php
@@ -13,6 +13,11 @@
show_footer();
exit;
}
+ if(isset($select))
+ {
+ unset($hostid);
+ }
+
if(isset($hostid)&&!check_right("Host","R",$hostid))
{
show_table_header("<font color=\"AA0000\">No permissions !</font
@@ -51,6 +56,26 @@
}
echo "</font>";
+ if(!isset($hostid)&&isset($select_form)&&!isset($select))
+ {
+ show_table_v_delimiter();
+ echo "<form name=\"form1\" method=\"get\" action=\"latest.php?select=true\">
+ <input type=\"text\" name=\"select\" value=\"$txt_select\">
+ <input type=\"submit\" name=\"Select\" value=\"Select\">
+ </form>";
+ }
+ else
+ {
+ show_table_v_delimiter();
+ if(isset($select))
+ {
+ echo "<b>[<a href='latest.php?select_form=1'>Select</a>]</b>";
+ }
+ else
+ {
+ echo "[<a href='latest.php?select_form=1'>Select</a>]";
+ }
+ }
show_table_header_end();
if(!isset($sort))
@@ -67,13 +92,20 @@
}
}
- if(isset($hostid))
+ if(isset($hostid)||isset($select))
{
- $result=DBselect("select host from hosts where hostid=$hostid");
- $host=DBget_field($result,0,0);
echo "<br>";
- show_table_header("<a href=\"latest.php?hostid=$hostid\">$host</a>");
+ if(!isset($select))
+ {
+ $result=DBselect("select host from hosts where hostid=$hostid");
+ $host=DBget_field($result,0,0);
+ show_table_header("<a href=\"latest.php?hostid=$hostid\">$host</a>");
+ }
+ else
+ {
+ show_table_header("Description is like *$select*");
+ }
# show_table_header_begin();
# echo "<a href=\"latest.php?hostid=$hostid\">$host</a>";
# show_table3_v_delimiter();
@@ -82,13 +114,24 @@
cr();
echo "<TR BGCOLOR=\"CCCCCC\">";
cr();
+ if(isset($select))
+ {
+ echo "<TD><B>Host</B></TD>";
+ }
if(!isset($sort)||(isset($sort)&&($sort=="description")))
{
echo "<TD><B>DESCRIPTION</B></TD>";
}
else
{
- echo "<TD><B><a href=\"latest.php?hostid=$hostid&sort=description\">Description</B></TD>";
+ if(isset($select))
+ {
+ echo "<TD><B><a href=\"latest.php?select=$select&sort=description\">Description</B></TD>";
+ }
+ else
+ {
+ echo "<TD><B><a href=\"latest.php?hostid=$hostid&sort=description\">Description</B></TD>";
+ }
}
if(isset($sort)&&($sort=="lastcheck"))
{
@@ -96,7 +139,14 @@
}
else
{
- echo "<TD WIDTH=\"12%\"><B><a href=\"latest.php?hostid=$hostid&sort=lastcheck\">Last check</B></TD>";
+ if(isset($select))
+ {
+ echo "<TD WIDTH=\"12%\"><B><a href=\"latest.php?select=$select&sort=lastcheck\">Last check</B></TD>";
+ }
+ else
+ {
+ echo "<TD WIDTH=\"12%\"><B><a href=\"latest.php?hostid=$hostid&sort=lastcheck\">Last check</B></TD>";
+ }
}
cr();
echo "<TD WIDTH=\"10%\" NOSAVE><B>Last value</B></TD>";
@@ -132,7 +182,14 @@
{
$sort="order by i.description";
}
- $result=DBselect("select h.host,i.itemid,i.description,i.lastvalue,i.prevvalue,i.lastclock,i.status,h.hostid,i.value_type from items i,hosts h where h.hostid=i.hostid and h.status in (0,2) and i.status in (0,2) and h.hostid=$hostid $sort");
+ if(isset($select))
+ {
+ $result=DBselect("select h.host,i.itemid,i.description,i.lastvalue,i.prevvalue,i.lastclock,i.status,h.hostid,i.value_type from items i,hosts h where h.hostid=i.hostid and h.status in (0,2) and i.status in (0,2) and i.description like '%$select%' $sort");
+ }
+ else
+ {
+ $result=DBselect("select h.host,i.itemid,i.description,i.lastvalue,i.prevvalue,i.lastclock,i.status,h.hostid,i.value_type from items i,hosts h where h.hostid=i.hostid and h.status in (0,2) and i.status in (0,2) and h.hostid=$hostid $sort");
+ }
while($row=DBfetch($result))
{
if(!check_right("Item","R",$row["itemid"]))
@@ -146,6 +203,10 @@
if($col++%2 == 1) { echo "<tr bgcolor=#DDDDDD>"; }
else { echo "<tr bgcolor=#EEEEEE>"; }
+ if(isset($select))
+ {
+ echo "<td>".$row["host"]."</td>";
+ }
echo "<td>".$row["description"]."</td>";
echo "<td>";
diff --git a/frontends/php/latestalarms.php b/frontends/php/latestalarms.php
index dfe60b98..efe89167 100644
--- a/frontends/php/latestalarms.php
+++ b/frontends/php/latestalarms.php
@@ -41,11 +41,11 @@
<?
if(!isset($start))
{
- $sql="select t.description,a.clock,a.value,t.triggerid from alarms a,triggers t where t.triggerid=a.triggerid order by clock desc limit 100";
+ $sql="select t.description,a.clock,a.value,t.triggerid from alarms a,triggers t where t.triggerid=a.triggerid order by clock desc limit 1000";
}
else
{
- $sql="select t.description,a.clock,a.value,t.triggerid from alarms a,triggers t where t.triggerid=a.triggerid order by clock desc limit ".($start+100);
+ $sql="select t.description,a.clock,a.value,t.triggerid from alarms a,triggers t where t.triggerid=a.triggerid order by clock desc limit ".($start+1000);
}
$result=DBselect($sql);
@@ -72,6 +72,8 @@
if($col++%2==0) { echo "<tr bgcolor=#DDDDDD>"; }
else { echo "<tr bgcolor=#EEEEEE>"; }
+ if($col>100) break;
+
echo "<TD>",date("Y.M.d H:i:s",$row["clock"]),"</TD>";
$description=$row["description"];
if( strstr($description,"%s"))
diff --git a/frontends/php/map.php b/frontends/php/map.php
index f42d8a0d..3ded71a2 100644
--- a/frontends/php/map.php
+++ b/frontends/php/map.php
@@ -145,7 +145,7 @@
# ImageDestroy($img);
}
- ImageStringUp($im,0,$width-10,$height-4, "http://zabbix.sourceforge.net", $gray);
+ ImageStringUp($im,0,imagesx($im)-10,imagesy($im)-50, "http://zabbix.sourceforge.net", $gray);
ImagePng($im);
ImageDestroy($im);
diff --git a/frontends/php/report2.php b/frontends/php/report2.php
index 6fc653f8..1088d65f 100644
--- a/frontends/php/report2.php
+++ b/frontends/php/report2.php
@@ -91,7 +91,6 @@
echo "</table>\n";
}
?>
-
<?
show_footer();
?>
diff --git a/frontends/php/services.php b/frontends/php/services.php
index ca4a9f48..89fabaea 100644
--- a/frontends/php/services.php
+++ b/frontends/php/services.php
@@ -309,6 +309,10 @@
{
$servicedownid_=DBget_field($result,$i,0);
$name_=DBget_field($result,$i,2);
+ if( strstr($name_,"%s"))
+ {
+ $name_=expand_trigger_description(DBget_field($result,$i,1));
+ }
echo "<OPTION VALUE='$servicedownid_'>$name_";
}
echo "</SELECT>";
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index 9b8454a9..df6d8ceb 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -201,7 +201,7 @@
<INPUT NAME=\"onlytrue\" TYPE=\"HIDDEN\" value=\"$onlytrue\">
<INPUT NAME=\"noactions\" TYPE=\"HIDDEN\" value=\"$noactions\">
<INPUT NAME=\"select\" TYPE=\"HIDDEN\" value=\"$select\">
- </form>";
+ </form>";
}
show_table_header_end();
echo "<br>";
diff --git a/frontends/php/trend.php b/frontends/php/trend.php
index 97fec832..12e3468d 100644
--- a/frontends/php/trend.php
+++ b/frontends/php/trend.php
@@ -7,6 +7,8 @@
# type
# trendavg
+ $start_time=time(NULL);
+
if(!isset($type))
{
$type="15min";
@@ -79,6 +81,26 @@
$min=array();
$max=array();
$avg=array();
+#if($DB_TYPE!="MYSQL")
+if(0)
+{
+// $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))";
+ $p=$to_time-$from_time;
+ $z=$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=$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;
+ }
+}
+else
+{
for($i=0;$i<900;$i++)
{
$result=DBselect("select count(value),min(value),max(value),avg(value) from history where itemid=$itemid and clock>$from_time+$i*($to_time-$from_time)/(900-50) and clock<$from_time+($i+1)*($to_time-$from_time)/(900-50)");
@@ -91,6 +113,8 @@
$nodata=0;
}
}
+}
+
for($i=0;$i<=$sizeY;$i+=$sizeY/5)
{
@@ -212,7 +236,10 @@
ImageString($im, 1,$shiftX+20, $sizeY+$shiftY+15, "AVG" , $darkyellow);
ImageString($im, 1,$shiftX+40, $sizeY+$shiftY+15, "MAX" , $darkred);
- ImageStringUp($im,0,2*$shiftX+$sizeX+40,$sizeY+2*$shiftY, "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);