summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-01-17 19:07:17 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-01-17 19:07:17 +0000
commit1ad5d81dff9ab714d1ca992c9a7344f192eeaa61 (patch)
tree60bd10f1932091d8ca981ec076b757f23cd9e8eb
parent122708ba14cc6df7904ec6e7d98f06e4c17ba0da (diff)
downloadzabbix-1ad5d81dff9ab714d1ca992c9a7344f192eeaa61.tar.gz
zabbix-1ad5d81dff9ab714d1ca992c9a7344f192eeaa61.tar.xz
zabbix-1ad5d81dff9ab714d1ca992c9a7344f192eeaa61.zip
- configurable format of icon labels for maps (Alexei)
- added column sysmaps.label_type (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@1615 97f52cf1-0a1b-0410-bd0e-c28be96e8082
-rw-r--r--ChangeLog2
-rw-r--r--create/mysql/schema.sql1
-rw-r--r--create/postgresql/schema.sql1
-rw-r--r--frontends/php/include/config.inc.php8
-rw-r--r--frontends/php/include/defines.inc.php5
-rw-r--r--frontends/php/include/local_en.inc.php5
-rw-r--r--frontends/php/map.php44
-rw-r--r--frontends/php/sysmaps.php60
-rw-r--r--upgrades/dbpatches/1.1alpha4_to_1.1alpha5/mysql/patch.sql2
-rw-r--r--upgrades/dbpatches/1.1alpha4_to_1.1alpha5/postgresql/patch.sql2
10 files changed, 103 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index 1e54a1fb..f4928b9b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
Changes for 1.1alpha5:
+ - configurable format of icon labels for maps (Alexei)
+ - added column sysmaps.label_type (Alexei)
- keep host selection when adding/deleting/updating item (Alexei)
- fix for complation of the agent under Solaris (Alexei)
- do not use hardcoded port 161 when adding from template (Alexei)
diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql
index 07b23d18..ad5a128b 100644
--- a/create/mysql/schema.sql
+++ b/create/mysql/schema.sql
@@ -124,6 +124,7 @@ CREATE TABLE sysmaps (
width int(4) DEFAULT '0' NOT NULL,
height int(4) DEFAULT '0' NOT NULL,
background varchar(64) DEFAULT '' NOT NULL,
+ label_type int(4) DEFAULT '0' NOT NULL,
PRIMARY KEY (sysmapid),
UNIQUE (name)
) type=InnoDB;
diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql
index ef9fbc04..7ffc8715 100644
--- a/create/postgresql/schema.sql
+++ b/create/postgresql/schema.sql
@@ -372,6 +372,7 @@ CREATE TABLE sysmaps (
width int4 DEFAULT '0' NOT NULL,
height int4 DEFAULT '0' NOT NULL,
background varchar(64) DEFAULT '' NOT NULL,
+ label_type int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (sysmapid)
);
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 79baf9ef..c9b799e6 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -2992,7 +2992,7 @@ echo "</head>";
# Update System Map
- function update_sysmap($sysmapid,$name,$width,$height,$background)
+ function update_sysmap($sysmapid,$name,$width,$height,$background,$label_type)
{
global $ERROR_MSG;
@@ -3002,7 +3002,7 @@ echo "</head>";
return 0;
}
- $sql="update sysmaps set name='$name',width=$width,height=$height,background='$background' where sysmapid=$sysmapid";
+ $sql="update sysmaps set name='$name',width=$width,height=$height,background='$background',label_type=$label_type where sysmapid=$sysmapid";
return DBexecute($sql);
}
@@ -3036,7 +3036,7 @@ echo "</head>";
# Add System Map
- function add_sysmap($name,$width,$height,$background)
+ function add_sysmap($name,$width,$height,$background,$label_type)
{
global $ERROR_MSG;
@@ -3046,7 +3046,7 @@ echo "</head>";
return 0;
}
- $sql="insert into sysmaps (name,width,height,background) values ('$name',$width,$height,'$background')";
+ $sql="insert into sysmaps (name,width,height,background,label_type) values ('$name',$width,$height,'$background',$label_type)";
return DBexecute($sql);
}
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index c707dc60..2011487a 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -60,6 +60,11 @@
define("GRAPH_YAXIS_TYPE_CALCULATED",0);
define("GRAPH_YAXIS_TYPE_FIXED",1);
+ define("MAP_LABEL_TYPE_HOSTLABEL",0);
+ define("MAP_LABEL_TYPE_IP",1);
+ define("MAP_LABEL_TYPE_HOSTNAME",2);
+ define("MAP_LABEL_TYPE_NOTHING",3);
+
define("ITEM_TYPE_ZABBIX",0);
define("ITEM_TYPE_SNMPV1",1);
define("ITEM_TYPE_TRAPPER",2);
diff --git a/frontends/php/include/local_en.inc.php b/frontends/php/include/local_en.inc.php
index ccd8c2d5..418b4ba4 100644
--- a/frontends/php/include/local_en.inc.php
+++ b/frontends/php/include/local_en.inc.php
@@ -376,6 +376,11 @@
define("S_NO_MAPS_TO_DISPLAY", "No maps to display");
define("S_SELECT_MAP_TO_DISPLAY", "Select map to display");
define("S_SELECT_MAP_DOT_DOT_DOT", "Select map...");
+ define("S_BACKGROUND_IMAGE", "Background image");
+ define("S_ICON_LABEL_TYPE", "Icon label type");
+ define("S_HOST_LABEL", "Host label");
+ define("S_HOST_NAME", "Host name");
+ define("S_NOTHING", "Nothing");
// media.php
define("S_MEDIA", "Media");
diff --git a/frontends/php/map.php b/frontends/php/map.php
index 3ac814ad..669df00e 100644
--- a/frontends/php/map.php
+++ b/frontends/php/map.php
@@ -28,12 +28,14 @@
$grid=50;
- $result=DBselect("select name,width,height,background from sysmaps where sysmapid=".$_GET["sysmapid"]);
+ $result=DBselect("select * from sysmaps where sysmapid=".$_GET["sysmapid"]);
+ $row=DBfetch($result);
- $name=DBget_field($result,0,0);
- $width=DBget_field($result,0,1);
- $height=DBget_field($result,0,2);
- $background=DBget_field($result,0,3);
+ $name=$row["name"];
+ $width=$row["width"];
+ $height=$row["height"];
+ $background=$row["background"];
+ $label_type=$row["label_type"];
// Header( "Content-type: text/html");
if(MAP_OUTPUT_FORMAT == "JPG") Header( "Content-type: image/jpeg");
@@ -230,7 +232,7 @@
# Draw hosts
$icons=array();
- $result=DBselect("select h.host,sh.shostid,sh.sysmapid,sh.hostid,sh.label,sh.x,sh.y,h.status,sh.icon,sh.icon_on from sysmaps_hosts sh,hosts h where sh.sysmapid=".$_GET["sysmapid"]." and h.hostid=sh.hostid");
+ $result=DBselect("select h.host,sh.shostid,sh.sysmapid,sh.hostid,sh.label,sh.x,sh.y,h.status,sh.icon,sh.icon_on,h.ip from sysmaps_hosts sh,hosts h where sh.sysmapid=".$_GET["sysmapid"]." and h.hostid=sh.hostid");
for($i=0;$i<DBnum_rows($result);$i++)
{
$host=DBget_field($result,$i,0);
@@ -243,6 +245,7 @@
$status=DBget_field($result,$i,7);
$icon=DBget_field($result,$i,8);
$icon_on=DBget_field($result,$i,9);
+ $ip=DBget_field($result,$i,10);
$result1=DBselect("select count(distinct t.triggerid) from items i,functions f,triggers t,hosts h where h.hostid=i.hostid and i.hostid=$hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.value=1 and t.status=0 and h.status=".HOST_STATUS_MONITORED." and i.status=0");
@@ -283,12 +286,27 @@
// imagecolortransparent ($img, 0, 0, 0);
ImageCopy($im,$img,$x,$y,0,0,ImageSX($img),ImageSY($img));
- if($label!="")
+ $first_line="";
+ if($label_type==MAP_LABEL_TYPE_HOSTNAME)
{
- $x1=$x+ImageSX($img)/2-ImageFontWidth(2)*strlen($label)/2;
+ $first_line=$host;
+ }
+ else if($label_type==MAP_LABEL_TYPE_HOSTLABEL)
+ {
+ $first_line=$label;
+ }
+ else if($label_type==MAP_LABEL_TYPE_IP)
+ {
+ $first_line=$ip;
+ }
+
+ if($first_line!="")
+ {
+
+ $x1=$x+ImageSX($img)/2-ImageFontWidth(2)*strlen($first_line)/2;
$y1=$y+ImageSY($img);
- ImageFilledRectangle($im,$x1-2, $y1,$x1+ImageFontWidth(2)*strlen($label), $y1+ImageFontHeight(2),$white);
- ImageString($im, 2, $x1, $y1, $label,$black);
+ ImageFilledRectangle($im,$x1-2, $y1,$x1+ImageFontWidth(2)*strlen($first_line), $y1+ImageFontHeight(2),$white);
+ ImageString($im, 2, $x1, $y1, $first_line,$black);
}
if($status == HOST_STATUS_NOT_MONITORED)
@@ -325,7 +343,11 @@
}
}
$x1=$x+ImageSX($img)/2-ImageFontWidth(2)*strlen($label)/2;
- $y1=$y+ImageSY($img)+ImageFontHeight(2);
+ $y1=$y+ImageSY($img);
+ if($first_line!="")
+ {
+ $y1=$y1+ImageFontHeight(2);
+ }
ImageFilledRectangle($im,$x1-2, $y1,$x1+ImageFontWidth(2)*strlen($label), $y1+ImageFontHeight(2),$white);
ImageString($im, 2, $x1, $y1, $label,$color);
diff --git a/frontends/php/sysmaps.php b/frontends/php/sysmaps.php
index 2f6d6f88..886658ae 100644
--- a/frontends/php/sysmaps.php
+++ b/frontends/php/sysmaps.php
@@ -40,12 +40,12 @@
{
if($_GET["register"]=="add")
{
- $result=add_sysmap($_GET["name"],$_GET["width"],$_GET["height"],$_GET["background"]);
+ $result=add_sysmap($_GET["name"],$_GET["width"],$_GET["height"],$_GET["background"],$_GET["label_type"]);
show_messages($result,"Network map added","Cannot add network map");
}
if($_GET["register"]=="update")
{
- $result=update_sysmap($_GET["sysmapid"],$_GET["name"],$_GET["width"],$_GET["height"],$_GET["background"]);
+ $result=update_sysmap($_GET["sysmapid"],$_GET["name"],$_GET["width"],$_GET["height"],$_GET["background"],$_GET["label_type"]);
show_messages($result,"Network map updated","Cannot update network map");
}
if($_GET["register"]=="delete")
@@ -98,11 +98,13 @@
if(isset($_GET["sysmapid"]))
{
- $result=DBselect("select s.sysmapid,s.name,s.width,s.height,s.background from sysmaps s where sysmapid=".$_GET["sysmapid"]);
- $name=DBget_field($result,0,1);
- $width=DBget_field($result,0,2);
- $height=DBget_field($result,0,3);
- $background=DBget_field($result,0,4);
+ $result=DBselect("select * from sysmaps where sysmapid=".$_GET["sysmapid"]);
+ $row=DBfetch($result);
+ $name=$row["name"];
+ $width=$row["width"];
+ $height=$row["height"];
+ $background=$row["background"];
+ $label_type=$row["label_type"];
}
else
{
@@ -110,6 +112,7 @@
$width=800;
$height=600;
$background="";
+ $label_type=0;
}
show_form_begin("sysmaps.map");
@@ -123,22 +126,22 @@
{
echo "<input class=\"biginput\" name=\"sysmapid\" type=\"hidden\" value=".$_GET["sysmapid"].">";
}
- echo "Name";
+ echo S_NAME;
show_table2_h_delimiter();
echo "<input class=\"biginput\" name=\"name\" value=\"$name\" size=32>";
show_table2_v_delimiter($col++);
- echo "Width";
+ echo S_WIDTH;
show_table2_h_delimiter();
echo "<input class=\"biginput\" name=\"width\" size=5 value=\"$width\">";
show_table2_v_delimiter($col++);
- echo "Height";
+ echo S_HEIGHT;
show_table2_h_delimiter();
echo "<input class=\"biginput\" name=\"height\" size=5 value=\"$height\">";
show_table2_v_delimiter($col++);
- echo "Background image";
+ echo S_BACKGROUND_IMAGE;
show_table2_h_delimiter();
echo "<select class=\"biginput\" name=\"background\" size=1>";
$result=DBselect("select name from images where imagetype=2 order by name");
@@ -147,7 +150,6 @@
{
$name=DBget_field($result,$i,0);
if(isset($_GET["sysmapid"]) && ($background==$name))
-// if(isset($_GET["hostid"]) && ($_GET["icon"]==$icons[$i]))
{
echo "<OPTION VALUE='".$name."' SELECTED>".$name;
}
@@ -158,6 +160,40 @@
}
echo "</SELECT>";
+ show_table2_v_delimiter($col++);
+ echo S_ICON_LABEL_TYPE;
+ show_table2_h_delimiter();
+ echo "<select class=\"biginput\" name=\"label_type\" size=1>";
+ if($label_type==0)
+ {
+ echo "<OPTION VALUE='0' SELECTED>".S_HOST_LABEL;
+ echo "<OPTION VALUE='1'>".S_IP_ADDRESS;
+ echo "<OPTION VALUE='2'>".S_HOST_NAME;
+ echo "<OPTION VALUE='3'>".S_NOTHING;
+ }
+ else if($label_type==1)
+ {
+ echo "<OPTION VALUE='0'>".S_HOST_LABEL;
+ echo "<OPTION VALUE='1' SELECTED>".S_IP_ADDRESS;
+ echo "<OPTION VALUE='2'>".S_HOST_NAME;
+ echo "<OPTION VALUE='3'>".S_NOTHING;
+ }
+ else if($label_type==2)
+ {
+ echo "<OPTION VALUE='0'>".S_HOST_LABEL;
+ echo "<OPTION VALUE='1'>".S_IP_ADDRESS;
+ echo "<OPTION VALUE='2' SELECTED>".S_HOST_NAME;
+ echo "<OPTION VALUE='3'>".S_NOTHING;
+ }
+ else if($label_type==3)
+ {
+ echo "<OPTION VALUE='0'>".S_HOST_LABEL;
+ echo "<OPTION VALUE='1'>".S_IP_ADDRESS;
+ echo "<OPTION VALUE='2'>".S_HOST_NAME;
+ echo "<OPTION VALUE='3' SELECTED>".S_NOTHING;
+ }
+ echo "</SELECT>";
+
show_table2_v_delimiter2();
echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"add\">";
if(isset($_GET["sysmapid"]))
diff --git a/upgrades/dbpatches/1.1alpha4_to_1.1alpha5/mysql/patch.sql b/upgrades/dbpatches/1.1alpha4_to_1.1alpha5/mysql/patch.sql
index 94c0b8fb..d6aa116a 100644
--- a/upgrades/dbpatches/1.1alpha4_to_1.1alpha5/mysql/patch.sql
+++ b/upgrades/dbpatches/1.1alpha4_to_1.1alpha5/mysql/patch.sql
@@ -27,3 +27,5 @@ update hosts set available=1 where status=0;
update hosts set available=2 where status=2;
update hosts set status=0 where status=2;
+
+alter table sysmaps add label_type int(4) DEFAULT '0' NOT NULL;
diff --git a/upgrades/dbpatches/1.1alpha4_to_1.1alpha5/postgresql/patch.sql b/upgrades/dbpatches/1.1alpha4_to_1.1alpha5/postgresql/patch.sql
index ae4d1500..f9340281 100644
--- a/upgrades/dbpatches/1.1alpha4_to_1.1alpha5/postgresql/patch.sql
+++ b/upgrades/dbpatches/1.1alpha4_to_1.1alpha5/postgresql/patch.sql
@@ -30,3 +30,5 @@ update hosts set available=1 where status=0;
update hosts set available=2 where status=2;
update hosts set status=0 where status=2;
+
+alter table sysmaps add label_type int4 DEFAULT '0' NOT NULL;