diff options
author | james_wells <james_wells@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-11-05 03:28:01 +0000 |
---|---|---|
committer | james_wells <james_wells@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2005-11-05 03:28:01 +0000 |
commit | b08a351860b379d09344887a4aa572be736be9b5 (patch) | |
tree | 9f45bfe67fc1f6c4845b10e5094c2ceb0703962f | |
parent | d98930885119abd5b9b21c1254d479857681acbb (diff) | |
download | zabbix-b08a351860b379d09344887a4aa572be736be9b5.tar.gz zabbix-b08a351860b379d09344887a4aa572be736be9b5.tar.xz zabbix-b08a351860b379d09344887a4aa572be736be9b5.zip |
Applied MySQL reconnect patch.
zabbix_tmp/src/libs/zbxdbhigh/db.c
Applied Multiple Server Patch.
zabbix/create/mysql/schema.sql
zabbix/create/postgresql/schema.sql
zabbix/frontends/php/include/config.inc.php
zabbix/frontends/php/include/forms.inc.php
zabbix/frontends/php/include/items.inc.php
zabbix/frontends/php/include/locales/de_de.inc.php
zabbix/frontends/php/include/locales/en_gb.inc.php
zabbix/frontends/php/include/locales/fr_fr.inc.php
zabbix/frontends/php/include/locales/it_it.inc.php
zabbix/frontends/php/include/locales/lv_lv.inc.php
zabbix/frontends/php/include/locales/ru_ru.inc.php
zabbix/frontends/php/include/locales/sp_sp.inc.php
zabbix/frontends/php/items.php
zabbix/frontends/php/servers.php
zabbix/include/common.h
zabbix/misc/conf/zabbix_server.conf
zabbix/src/zabbix_server/housekeeper/housekeeper.c
zabbix/src/zabbix_server/housekeeper/housekeeper.h
zabbix/src/zabbix_server/pinger/pinger.c
zabbix/src/zabbix_server/pinger/pinger.h
zabbix/src/zabbix_server/poller/poller.c
zabbix/src/zabbix_server/poller/poller.h
zabbix/src/zabbix_server/server.c
zabbix/src/zabbix_server/timer/timer.c
zabbix/src/zabbix_server/timer/timer.h
zabbix/upgrades/dbpatches/1.1beta2_to_1.1beta3/mysql/patch.sql
zabbix/upgrades/dbpatches/1.1beta2_to_1.1beta3/postgresql/patch.sql
git-svn-id: svn://svn.zabbix.com/trunk@2277 97f52cf1-0a1b-0410-bd0e-c28be96e8082
29 files changed, 313 insertions, 58 deletions
@@ -1,5 +1,7 @@ Changes for 1.1beta3: + - Applied MySQL reconnect patch. (James) + - Applied multiple server patch. (James) - Applied graph generation fix. Thanks to Elkor (James) - Updated displayed version in UI to 1.1beta3 (James) - Applied span inconsistency patch. Thanks to Elkor (James) diff --git a/create/mysql/schema.sql b/create/mysql/schema.sql index 0eae6ca5..905aaa95 100644 --- a/create/mysql/schema.sql +++ b/create/mysql/schema.sql @@ -275,6 +275,7 @@ CREATE TABLE history_str ( CREATE TABLE hosts ( hostid int(4) NOT NULL auto_increment, + serverid int(4) DEFAULT '1' NOT NULL, host varchar(64) DEFAULT '' NOT NULL, useip int(1) DEFAULT '1' NOT NULL, ip varchar(15) DEFAULT '127.0.0.1' NOT NULL, @@ -288,6 +289,7 @@ CREATE TABLE hosts ( PRIMARY KEY (hostid), UNIQUE (host), KEY (status) + KEY (serverid) ) type=InnoDB; -- @@ -301,6 +303,7 @@ CREATE TABLE items ( snmp_oid varchar(255) DEFAULT '' NOT NULL, snmp_port int(4) DEFAULT '161' NOT NULL, hostid int(4) NOT NULL, + serverid int(4) DEFAULT '1' NOT NULL, description varchar(255) DEFAULT '' NOT NULL, key_ varchar(64) DEFAULT '' NOT NULL, delay int(4) DEFAULT '0' NOT NULL, @@ -738,3 +741,13 @@ CREATE TABLE autoreg ( hostid int(4) DEFAULT '0' NOT NULL, PRIMARY KEY (id) ) type=InnoDB; + +CREATE TABLE servers ( + serverid int(4) NOT NULL auto_increment, + host varchar(64) DEFAULT '' NOT NULL, + ip varchar(15) DEFAULT '127.0.0.1' NOT NULL, + port int(4) DEFAULT '0' NOT NULL, + PRIMARY KEY (serverid), + UNIQUE (host) +) type=InnoDB; + diff --git a/create/postgresql/schema.sql b/create/postgresql/schema.sql index 1d6aafbe..4d4d915b 100644 --- a/create/postgresql/schema.sql +++ b/create/postgresql/schema.sql @@ -25,6 +25,7 @@ CREATE TABLE hosts ( hostid serial, + serverid int4 DEFAULT '1' NOT NULL, host varchar(64) DEFAULT '' NOT NULL, useip int4 DEFAULT '0' NOT NULL, ip varchar(15) DEFAULT '127.0.0.1' NOT NULL, @@ -35,10 +36,12 @@ CREATE TABLE hosts ( error varchar(128) DEFAULT '' NOT NULL, available int4 DEFAULT '0' NOT NULL, PRIMARY KEY (hostid) + FOREIGN KEY (serverid) REFERENCES servers ); CREATE INDEX hosts_status on hosts (status); CREATE UNIQUE INDEX hosts_host on hosts (host); +CREATE INDEX hosts_server on hosts (serverid); -- -- Table structure for table 'items' @@ -51,6 +54,7 @@ CREATE TABLE items ( snmp_oid varchar(255) DEFAULT '' NOT NULL, snmp_port int4 DEFAULT '161' NOT NULL, hostid int4 NOT NULL, + serverid int4 DEFAULT '1' NOT NULL, description varchar(255) DEFAULT '' NOT NULL, key_ varchar(64) DEFAULT '' NOT NULL, delay int4 DEFAULT '0' NOT NULL, @@ -79,12 +83,14 @@ CREATE TABLE items ( logtimefmt varchar(64) DEFAULT '' NOT NULL, PRIMARY KEY (itemid), FOREIGN KEY (hostid) REFERENCES hosts + FOREIGN KEY (serverid) REFERENCES servers ); CREATE UNIQUE INDEX items_hostid_key on items (hostid,key_); --CREATE INDEX items_hostid on items (hostid); CREATE INDEX items_nextcheck on items (nextcheck); CREATE INDEX items_status on items (status); +CREATE INDEX items_server on items (serverid); -- -- Table structure for table 'config' @@ -727,4 +733,17 @@ CREATE TABLE autoreg ( PRIMARY KEY (id) ); +-- +-- Table structure for table 'servers' +-- + +CREATE TABLE servers ( + serverid serial + host varchar(64) DEFAULT '' NOT NULL, + ip varchar(15) DEFAULT '127.0.0.1' NOT NULL, + port int4 DEFAULT '0' NOT NULL, + PRIMARY KEY (serverid), + PRIMARY KEY (serverid) +); + VACUUM ANALYZE; diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 2dcd3e6e..7c6ae7eb 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -1100,7 +1100,7 @@ echo "</head>"; ), "configuration"=>array( "label"=>S_CONFIGURATION, - "pages"=>array("config.php","users.php","audit.php","hosts.php","items.php","triggers.php","sysmaps.php","graphs.php","screenconf.php","services.php","sysmap.php","media.php","screenedit.php","actions.php","graph.php"), + "pages"=>array("config.php","users.php","audit.php","hosts.php","items.php","triggers.php","sysmaps.php","graphs.php","screenconf.php","services.php","sysmap.php","media.php","screenedit.php","actions.php","graph.php","servers.php"), "level2"=>array( array("label"=>S_GENERAL,"url"=>"config.php"), array("label"=>S_USERS,"url"=>"users.php"), @@ -1111,6 +1111,7 @@ echo "</head>"; array("label"=>S_MAPS,"url"=>"sysmaps.php"), array("label"=>S_GRAPHS,"url"=>"graphs.php"), array("label"=>S_SCREENS,"url"=>"screenconf.php"), + array("label"=>S_MENU_SERVERS,"url"=>"servers.php"), array("label"=>S_IT_SERVICES,"url"=>"services.php") ) ), diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index f13e14c2..ece7a259 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -289,10 +289,11 @@ ; $formula=@iif(isset($_REQUEST["formula"]),$_REQUEST["formula"],"1"); $logtimefmt=@iif(isset($_REQUEST["logtimefmt"]),$_REQUEST["logtimefmt"],""); + $serverid=@iif(isset($_REQUEST["serverid"]),$_REQUEST["serverid"],1); if(isset($_REQUEST["register"])&&($_REQUEST["register"] == "change")) { - $result=DBselect("select i.description, i.key_, h.host, h.port, i.delay, i.history, i.status, i.type, i.snmp_community,i.snmp_oid,i.value_type,i.trapper_hosts,i.snmp_port,i.units,i.multiplier,h.hostid,i.delta,i.trends,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,i.logtimefmt from items i,hosts h where i.itemid=".$_REQUEST["itemid"]." and h.hostid=i.hostid"); + $result=DBselect("select i.description, i.key_, h.host, h.port, i.delay, i.history, i.status, i.type, i.snmp_community,i.snmp_oid,i.value_type,i.trapper_hosts,i.snmp_port,i.units,i.multiplier,h.hostid,i.delta,i.trends,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,i.logtimefmt,i.serverid from items i,hosts h where i.itemid=".$_REQUEST["itemid"]." and h.hostid=i.hostid"); $description=DBget_field($result,0,0); $key=DBget_field($result,0,1); @@ -320,6 +321,7 @@ $formula=DBget_field($result,0,22); $logtimefmt=DBget_field($result,0,23); + $serverid=DBget_field($result,0,24); } show_form_begin("items.item"); @@ -356,6 +358,33 @@ } echo "</select>"; + $result=DBselect("select serverid,host from servers"); + if(DBnum_rows($result)>=2) + { + show_table2_v_delimiter($col++); + echo S_SERVERNAME; + show_table2_h_delimiter(); + echo "<select class=\"biginput\" name=\"serverid\" value=\"1\">"; + while($row=DBfetch($result)) + { + $serverid_=$row["serverid"]; + $host_=$row["host"]; + if($serverid==$serverid_) + { + echo "<option value=\"$serverid_\" selected>$host_"; + } + else + { + echo "<option value=\"$serverid_\">$host_"; + } + } + echo "</select>"; + } + else + { + echo "<input type=\"hidden\" value=1 name=\"serverid\">"; + } + show_table2_v_delimiter($col++); echo S_TYPE; show_table2_h_delimiter(); @@ -1495,4 +1524,57 @@ show_table2_header_end(); } + + + + + + + function insert_zabbix_server_form($page,$serverid=0,$create=1) + { + $host = $serverip = $serverport = ""; + $col=0; + + $sql="select s.serverid,s.host,s.ip,s.port from servers s where s.serverid=$serverid"; + $result=DBselect($sql); + while($row=DBfetch($result)) + { + $host=$row["host"]; + $serverip=$row["ip"]; + $serverport=$row["port"]; + } + + show_form_begin("index.servers"); + echo "Servers"; + + show_table2_v_delimiter($col++); + echo "<form method=\"post\" action=\"$page\">"; + + echo S_SERVER_HOST; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"host\" value=\"$host\" size=20>"; + + show_table2_v_delimiter($col++); + echo S_SERVER_IP; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"serverip\" value=\"$serverip\" size=20>"; + + show_table2_v_delimiter($col++); + echo S_SERVER_PORT; + show_table2_h_delimiter(); + echo "<input class=\"biginput\" name=\"serverport\" value=\"$serverport\" size=20>"; + + show_table2_v_delimiter2(); + if($serverid==0) + { + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"Add\">"; + } + else + { + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"Update\">"; + } + echo "<input class=\"button\" type=\"submit\" name=\"register\" value=\"Delete\">"; + show_table2_header_end(); + } + ?> diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index d9bc8ebe..27407885 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -21,13 +21,13 @@ <?php # Update Item definition for selected group - function update_item_in_group($groupid,$itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt) + function update_item_in_group($groupid,$itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt,$serverid) { $sql="select i.itemid,i.hostid from hosts_groups hg,items i where hg.groupid=$groupid and i.key_=\"$key\" and hg.hostid=i.hostid"; $result=DBexecute($sql); while($row=DBfetch($result)) { - update_item($row["itemid"],$description,$key,$row["hostid"],$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt); + update_item($row["itemid"],$description,$key,$row["hostid"],$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt,$serverid); } return 1; } @@ -58,20 +58,20 @@ # Add Item definition to selected group - function add_item_to_group($groupid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt) + function add_item_to_group($groupid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt,$serverid) { $sql="select hostid from hosts_groups where groupid=$groupid"; $result=DBexecute($sql); while($row=DBfetch($result)) { - add_item($description,$key,$row["hostid"],$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt); + add_item($description,$key,$row["hostid"],$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt,$serverid); } return 1; } # Add Item definition - function add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt) + function add_item($description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt,$serverid) { if(!check_right("Item","A",0)) { @@ -113,7 +113,7 @@ $snmpv3_authpassphrase=addslashes($snmpv3_authpassphrase); $snmpv3_privpassphrase=addslashes($snmpv3_privpassphrase); - $sql="insert into items (description,key_,hostid,delay,history,nextcheck,status,type,snmp_community,snmp_oid,value_type,trapper_hosts,snmp_port,units,multiplier,delta,snmpv3_securityname,snmpv3_securitylevel,snmpv3_authpassphrase,snmpv3_privpassphrase,formula,trends,logtimefmt) values ('$description','$key',$hostid,$delay,$history,0,$status,$type,'$snmp_community','$snmp_oid',$value_type,'$trapper_hosts',$snmp_port,'$units',$multiplier,$delta,'$snmpv3_securityname',$snmpv3_securitylevel,'$snmpv3_authpassphrase','$snmpv3_privpassphrase','$formula',$trends,'$logtimefmt')"; + $sql="insert into items (description,key_,hostid,delay,history,nextcheck,status,type,snmp_community,snmp_oid,value_type,trapper_hosts,snmp_port,units,multiplier,delta,snmpv3_securityname,snmpv3_securitylevel,snmpv3_authpassphrase,snmpv3_privpassphrase,formula,trends,logtimefmt,serverid) values ('$description','$key',$hostid,$delay,$history,0,$status,$type,'$snmp_community','$snmp_oid',$value_type,'$trapper_hosts',$snmp_port,'$units',$multiplier,$delta,'$snmpv3_securityname',$snmpv3_securitylevel,'$snmpv3_authpassphrase','$snmpv3_privpassphrase','$formula',$trends,'$logtimefmt',$serverid)"; $result=DBexecute($sql); if($result) { @@ -142,7 +142,7 @@ # Update Item definition - function update_item($itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt) + function update_item($itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt,$serverid) { if(!check_right("Item","U",$itemid)) { @@ -176,7 +176,7 @@ $sql="update items set lastlogsize=0 where itemid=$itemid and key_<>'$key'"; DBexecute($sql); - $sql="update items set description='$description',key_='$key',hostid=$hostid,delay=$delay,history=$history,nextcheck=0,status=$status,type=$type,snmp_community='$snmp_community',snmp_oid='$snmp_oid',value_type=$value_type,trapper_hosts='$trapper_hosts',snmp_port=$snmp_port,units='$units',multiplier=$multiplier,delta=$delta,snmpv3_securityname='$snmpv3_securityname',snmpv3_securitylevel=$snmpv3_securitylevel,snmpv3_authpassphrase='$snmpv3_authpassphrase',snmpv3_privpassphrase='$snmpv3_privpassphrase',formula='$formula',trends=$trends,logtimefmt='$logtimefmt' where itemid=$itemid"; + $sql="update items set description='$description',key_='$key',hostid=$hostid,delay=$delay,history=$history,nextcheck=0,status=$status,type=$type,snmp_community='$snmp_community',snmp_oid='$snmp_oid',value_type=$value_type,trapper_hosts='$trapper_hosts',snmp_port=$snmp_port,units='$units',multiplier=$multiplier,delta=$delta,snmpv3_securityname='$snmpv3_securityname',snmpv3_securitylevel=$snmpv3_securitylevel,snmpv3_authpassphrase='$snmpv3_authpassphrase',snmpv3_privpassphrase='$snmpv3_privpassphrase',formula='$formula',trends=$trends,logtimefmt='$logtimefmt',serverid=$serverid where itemid=$itemid"; $result=DBexecute($sql); if($result) { @@ -231,7 +231,7 @@ $result2=DBselect($sql); if(DBnum_rows($result2)==0) { - add_item($item["description"],$item["key_"],$row["hostid"],$item["delay"],$item["history"],$item["status"],$item["type"],$item["snmp_community"],$item["snmp_oid"],$item["value_type"],$item["trapper_hosts"],$item["snmp_port"],$item["units"],$item["multiplier"],$item["delta"],$item["snmpv3_securityname"],$item["snmpv3_securitylevel"],$item["snmpv3_authpassphrase"],$item["snmpv3_privpassphrase"],$item["formula"],$item["trends"],$item["logtimefmt"]); + add_item($item["description"],$item["key_"],$row["hostid"],$item["delay"],$item["history"],$item["status"],$item["type"],$item["snmp_community"],$item["snmp_oid"],$item["value_type"],$item["trapper_hosts"],$item["snmp_port"],$item["units"],$item["multiplier"],$item["delta"],$item["snmpv3_securityname"],$item["snmpv3_securitylevel"],$item["snmpv3_authpassphrase"],$item["snmpv3_privpassphrase"],$item["formula"],$item["trends"],$item["logtimefmt"],$item["serverid"]); $host=get_host_by_hostid($row["hostid"]); info("Added to linked host ".$host["host"]); } @@ -286,7 +286,7 @@ if(DBnum_rows($result2)==1) { $row2=DBfetch($result2); - update_item($row2["itemid"],$item["description"],$item["key_"],$row["hostid"],$item["delay"],$item["history"],$item["status"],$item["type"],$item["snmp_community"],$item["snmp_oid"],$item["value_type"],$item["trapper_hosts"],$item["snmp_port"],$item["units"],$item["multiplier"],$item["delta"],$item["snmpv3_securityname"],$item["snmpv3_securitylevel"],$item["snmpv3_authpassphrase"],$item["snmpv3_privpassphrase"],$item["formula"],$item["trends"]); + update_item($row2["itemid"],$item["description"],$item["key_"],$row["hostid"],$item["delay"],$item["history"],$item["status"],$item["type"],$item["snmp_community"],$item["snmp_oid"],$item["value_type"],$item["trapper_hosts"],$item["snmp_port"],$item["units"],$item["multiplier"],$item["delta"],$item["snmpv3_securityname"],$item["snmpv3_securitylevel"],$item["snmpv3_authpassphrase"],$item["snmpv3_privpassphrase"],$item["formula"],$item["trends"],$item["logtimefmt"],$item["serverid"]); $host=get_host_by_hostid($row["hostid"]); info("Updated for linked host ".$host["host"]); } diff --git a/frontends/php/include/locales/de_de.inc.php b/frontends/php/include/locales/de_de.inc.php index 7b214aeb..49e51b2d 100644 --- a/frontends/php/include/locales/de_de.inc.php +++ b/frontends/php/include/locales/de_de.inc.php @@ -337,6 +337,7 @@ "S_ITEMS_ACTIVATED"=> "Elemente aktiviert", "S_CANNOT_ACTIVATE_ITEMS"=> "Elemente konnten nicht aktiviert werden", "S_ITEMS_DISABLED"=> "Elemente deaktiviert", + "S_SERVERNAME"=> "Server Name", "S_KEY"=> "Schlüssel", "S_DESCRIPTION"=> "Beschreibung", "S_UPDATE_INTERVAL"=> "Update Interval", @@ -453,6 +454,7 @@ "S_MENU_GRAPHS"=> "GRAPHEN", "S_MENU_SCREENS"=> "ÜBERSICHTSPLÄNE", "S_MENU_IT_SERVICES"=> "IT DIENSTE", + "S_MENU_SERVERS"=> "Zabbix Servers", "S_MENU_HOME"=> "START", "S_MENU_ABOUT"=> "ÜBER", "S_MENU_STATUS_OF_ZABBIX"=> "STATUS VON ZABBIX", diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php index 95c7845a..4a5ad97f 100644 --- a/frontends/php/include/locales/en_gb.inc.php +++ b/frontends/php/include/locales/en_gb.inc.php @@ -379,6 +379,7 @@ "S_CANNOT_ACTIVATE_ITEMS"=> "Cannot activate items", "S_ITEMS_DISABLED"=> "Items disabled", "S_CANNOT_DISABLE_ITEMS"=> "Cannot disable items", + "S_SERVERNAME"=> "Server Name", "S_KEY"=> "Key", "S_DESCRIPTION"=> "Description", "S_UPDATE_INTERVAL"=> "Update interval", @@ -497,6 +498,7 @@ "S_MENU_GRAPHS"=> "GRAPHS", "S_MENU_SCREENS"=> "SCREENS", "S_MENU_IT_SERVICES"=> "IT SERVICES", + "S_MENU_SERVERS"=> "Zabbix Servers", "S_MENU_HOME"=> "HOME", "S_MENU_ABOUT"=> "ABOUT", "S_MENU_STATUS_OF_ZABBIX"=> "STATUS OF ZABBIX", @@ -784,6 +786,13 @@ "S_HOST_PROFILES"=> "Host profiles", "S_HOST_PROFILES_BIG"=> "HOST PROFILES", +// servers.php + "S_SERVER_SERVERID"=> "Server ID", + "S_SERVER_HOST"=> "Server Name", + "S_SERVER_IP"=> "Server IP", + "S_SERVER_PORT"=> "Server Port", + +// Menu // Menu "S_HELP"=> "Help", diff --git a/frontends/php/include/locales/fr_fr.inc.php b/frontends/php/include/locales/fr_fr.inc.php index 6365bca7..b378202d 100644 --- a/frontends/php/include/locales/fr_fr.inc.php +++ b/frontends/php/include/locales/fr_fr.inc.php @@ -330,6 +330,7 @@ "S_ITEMS_ACTIVATED"=> "Items activés", "S_CANNOT_ACTIVATE_ITEMS"=> "Impossible d'activer les items", "S_ITEMS_DISABLED"=> "Items désactivés", + "S_SERVERNAME"=> "Server Name", "S_KEY"=> "Clé", "S_DESCRIPTION"=> "Description", "S_UPDATE_INTERVAL"=> "Invervale d'actualisation", @@ -446,6 +447,7 @@ "S_MENU_GRAPHS"=> "GRAPHIQUES", "S_MENU_SCREENS"=> "ÉCRANS", "S_MENU_IT_SERVICES"=> "SERVICES TI", + "S_MENU_SERVERS"=> "Zabbix Servers", "S_MENU_HOME"=> "ACCUEIL", "S_MENU_ABOUT"=> "A PROPOS", "S_MENU_STATUS_OF_ZABBIX"=> "STATUT OF ZABBIX", diff --git a/frontends/php/include/locales/it_it.inc.php b/frontends/php/include/locales/it_it.inc.php index f28ce122..d077aa67 100644 --- a/frontends/php/include/locales/it_it.inc.php +++ b/frontends/php/include/locales/it_it.inc.php @@ -332,6 +332,7 @@ "S_ITEMS_ACTIVATED"=> "Parametro attivato", "S_CANNOT_ACTIVATE_ITEMS"=> "Non posso attivare il parametro", "S_ITEMS_DISABLED"=> "Parametri disabilitati!", + "S_SERVERNAME"=> "Server Name", "S_KEY"=> "Chiave", "S_DESCRIPTION"=> "Descrizione", "S_UPDATE_INTERVAL"=> "Aggiorna ogni (in sec)", @@ -448,6 +449,7 @@ "S_MENU_GRAPHS"=> "GRAFICI", "S_MENU_SCREENS"=> "SCHERMATE", "S_MENU_IT_SERVICES"=> "SERVIZI IT", + "S_MENU_SERVERS"=> "Zabbix Servers", "S_MENU_HOME"=> "HOME", "S_MENU_ABOUT"=> "INFO", "S_MENU_STATUS_OF_ZABBIX"=> "STATO", diff --git a/frontends/php/include/locales/lv_lv.inc.php b/frontends/php/include/locales/lv_lv.inc.php index 3165e602..f33e7e24 100644 --- a/frontends/php/include/locales/lv_lv.inc.php +++ b/frontends/php/include/locales/lv_lv.inc.php @@ -330,6 +330,7 @@ "S_ITEMS_ACTIVATED"=> "Items activated", "S_CANNOT_ACTIVATE_ITEMS"=> "Cannot activate items", "S_ITEMS_DISABLED"=> "Items disabled", + "S_SERVERNAME"=> "Server Name", "S_KEY"=> "Key", "S_DESCRIPTION"=> "Description", "S_UPDATE_INTERVAL"=> "Update interval", @@ -446,6 +447,7 @@ "S_MENU_GRAPHS"=> "GRAPHS", "S_MENU_SCREENS"=> "SCREENS", "S_MENU_IT_SERVICES"=> "IT SERVICES", + "S_MENU_SERVERS"=> "Zabbix Servers", "S_MENU_HOME"=> "HOME", "S_MENU_ABOUT"=> "ABOUT", "S_MENU_STATUS_OF_ZABBIX"=> "STATUS OF ZABBIX", diff --git a/frontends/php/include/locales/ru_ru.inc.php b/frontends/php/include/locales/ru_ru.inc.php index 7d6243ba..d09f798e 100644 --- a/frontends/php/include/locales/ru_ru.inc.php +++ b/frontends/php/include/locales/ru_ru.inc.php @@ -330,6 +330,7 @@ "S_ITEMS_ACTIVATED"=> "Items activated", "S_CANNOT_ACTIVATE_ITEMS"=> "Cannot activate items", "S_ITEMS_DISABLED"=> "Items disabled", + "S_SERVERNAME"=> "Server Name", "S_KEY"=> "Key", "S_DESCRIPTION"=> "Description", "S_UPDATE_INTERVAL"=> "Update interval", @@ -446,6 +447,7 @@ "S_MENU_GRAPHS"=> "GRAPHS", "S_MENU_SCREENS"=> "SCREENS", "S_MENU_IT_SERVICES"=> "IT SERVICES", + "S_MENU_SERVERS"=> "Zabbix Servers", "S_MENU_HOME"=> "HOME", "S_MENU_ABOUT"=> "ABOUT", "S_MENU_STATUS_OF_ZABBIX"=> "STATUS OF ZABBIX", diff --git a/frontends/php/include/locales/sp_sp.inc.php b/frontends/php/include/locales/sp_sp.inc.php index 66173f16..837aa784 100644 --- a/frontends/php/include/locales/sp_sp.inc.php +++ b/frontends/php/include/locales/sp_sp.inc.php @@ -330,6 +330,7 @@ "S_ITEMS_ACTIVATED"=> "Items activados", "S_CANNOT_ACTIVATE_ITEMS"=> "No se puede activar items", "S_ITEMS_DISABLED"=> "Items desactivados", + "S_SERVERNAME"=> "Server Name", "S_KEY"=> "Key", "S_DESCRIPTION"=> "Descripción", "S_UPDATE_INTERVAL"=> "Intervalo de actualización", @@ -446,6 +447,7 @@ "S_MENU_GRAPHS"=> "GRAFICOS", "S_MENU_SCREENS"=> "PANTALLAS", "S_MENU_IT_SERVICES"=> "SERVICIOS TI", + "S_MENU_SERVERS"=> "Zabbix Servers", "S_MENU_HOME"=> "HOME", "S_MENU_ABOUT"=> "ACERCA DE", "S_MENU_STATUS_OF_ZABBIX"=> "ESTADO DE ZABBIX", diff --git a/frontends/php/items.php b/frontends/php/items.php index b592d223..ff4c690a 100644 --- a/frontends/php/items.php +++ b/frontends/php/items.php @@ -30,6 +30,14 @@ ?> <?php + $serverlist=array(); + $result=DBselect("select distinct serverid,host from servers"); + $servers=DBnum_rows($result); + while($row=DBfetch($result)) + { + $serverlist=$serverlist + array($row["serverid"]=>$row["host"]); + } + if(!check_anyright("Host","U")) { show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font @@ -63,14 +71,14 @@ { if($_REQUEST["action"]=="add to group") { - $itemid=add_item_to_group($_REQUEST["groupid"],$_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"]); + $itemid=add_item_to_group($_REQUEST["groupid"],$_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"],$_REQUEST["serverid"]); show_messages($itemid, S_ITEM_ADDED, S_CANNOT_ADD_ITEM); unset($_REQUEST["itemid"]); unset($itemid); } if($_REQUEST["action"]=="update in group") { - $result=update_item_in_group($_REQUEST["groupid"],$_REQUEST["itemid"],$_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"]); + $result=update_item_in_group($_REQUEST["groupid"],$_REQUEST["itemid"],$_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"],$_REQUEST["serverid"]); show_messages($result, S_ITEM_UPDATED, S_CANNOT_UPDATE_ITEM); unset($_REQUEST["itemid"]); } @@ -83,7 +91,7 @@ } if($_REQUEST["register"]=="update") { - $result=update_item($_REQUEST["itemid"],$_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"]); + $result=update_item($_REQUEST["itemid"],$_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"],$_REQUEST["serverid"]); update_item_in_templates($_REQUEST["itemid"]); show_messages($result, S_ITEM_UPDATED, S_CANNOT_UPDATE_ITEM); // unset($itemid); @@ -96,7 +104,7 @@ } if($_REQUEST["register"]=="add") { - $itemid=add_item($_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"]); + $itemid=add_item($_REQUEST["description"],$_REQUEST["key"],$_REQUEST["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"],$_REQUEST["serverid"]); add_item_to_linked_hosts($itemid); show_messages($itemid, S_ITEM_ADDED, S_CANNOT_ADD_ITEM); unset($_REQUEST["itemid"]); @@ -109,7 +117,7 @@ $hosts_notok=""; while($row=DBfetch($result)) { - $result2=add_item($_REQUEST["description"],$_REQUEST["key"],$row["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"]); + $result2=add_item($_REQUEST["description"],$_REQUEST["key"],$row["hostid"],$_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],$_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],$_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],$_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],$_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],$_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"],$_REQUEST["serverid"]); if($result2) { $hosts_ok=$hosts_ok." ".$row["host"]; @@ -238,10 +246,17 @@ // if(isset($_REQUEST["hostid"])&&!isset($_REQUEST["type"])) { table_begin(); + if($servers==1||$servers==0) + { table_header(array(S_ID,S_KEY,S_DESCRIPTION,nbsp(S_UPDATE_INTERVAL),S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,S_ERROR,S_ACTIONS)); + } + else + { + table_header(array(S_ID,S_SERVERNAME,S_KEY,S_DESCRIPTION,nbsp(S_UPDATE_INTERVAL),S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,S_ERROR,S_ACTIONS)); + } echo "<form method=\"get\" action=\"items.php\">"; echo "<input class=\"biginput\" name=\"hostid\" type=hidden value=".$_REQUEST["hostid"]." size=8>"; - $result=DBselect("select h.host,i.key_,i.itemid,i.description,h.port,i.delay,i.history,i.lastvalue,i.lastclock,i.status,i.nextcheck,h.hostid,i.type,i.trends,i.error from hosts h,items i where h.hostid=i.hostid and h.hostid=".$_REQUEST["hostid"]." order by h.host,i.key_,i.description"); + $result=DBselect("select h.host,i.key_,i.itemid,i.description,h.port,i.delay,i.history,i.lastvalue,i.lastclock,i.status,i.nextcheck,h.hostid,i.type,i.trends,i.serverid,i.error from hosts h,items i where h.hostid=i.hostid and h.hostid=".$_REQUEST["hostid"]." order by h.host,i.key_,i.description"); $col=0; while($row=DBfetch($result)) { @@ -311,9 +326,27 @@ { $error=array("value"=>$row["error"],"class"=>"on"); } - + if($servers==1||$servers==0) + { + table_row(array( + $input, + $row["key_"], + $row["description"], + $row["delay"], + $row["history"], + $row["trends"], + $type, + $status, + $error, + $actions + ),$col++); + } + else + { + $serverid=$row["serverid"]; table_row(array( $input, + $serverlist[$serverid], $row["key_"], $row["description"], $row["delay"], @@ -325,6 +358,7 @@ $actions ),$col++); } + } table_end(); show_form_begin(); @@ -26,10 +26,10 @@ automake echo Configuring... export CFLAGS="-Wall" #export CFLAGS="-Wall -pedantic" -./configure --enable-agent --enable-server --with-mysql --with-net-snmp --prefix=`pwd` 2>WARNINGS >/dev/null +./configure --enable-agent --enable-server --with-mysql --prefix=`pwd` echo Cleaning... -make clean >/dev/null +make clean echo Making... -make 2>>WARNINGS >/dev/null -echo Installing... -make install 2>>WARNINGS >/dev/null +make +#echo Installing... +#make install 2>>WARNINGS >/dev/null diff --git a/include/common.h b/include/common.h index 3a20f8ef..9b783f13 100644 --- a/include/common.h +++ b/include/common.h @@ -22,7 +22,7 @@ #include "sysinc.h" -#define ZABBIX_VERSION "1.1beta2" +#define ZABBIX_VERSION "1.1beta3" #define SUCCEED 0 #define FAIL (-1) @@ -31,6 +31,16 @@ #define TIMEOUT_ERROR (-4) #define AGENT_ERROR (-5) +/* + * Default Server ID is 1 + */ +#define SERVERD_ID 1 + +/* + * Default Server ID is 1 + */ +#define SERVERD_ID 1 + #define MAXFD 64 /* show debug info to stderr */ diff --git a/misc/conf/zabbix_server.conf b/misc/conf/zabbix_server.conf index 7606e034..f3f98957 100644 --- a/misc/conf/zabbix_server.conf +++ b/misc/conf/zabbix_server.conf @@ -4,6 +4,11 @@ ############ GENERAL PARAMETERS ################# +# This defines which server this is. +# Default value 1 +# This parameter must be between 1 and 255 +Server=1 + # Number of pre-forked instances of pollers # Default value is 6 # This parameter must be between 5 and 255 diff --git a/src/libs/zbxdbhigh/db.c b/src/libs/zbxdbhigh/db.c index 6e6f571c..243d4d35 100644 --- a/src/libs/zbxdbhigh/db.c +++ b/src/libs/zbxdbhigh/db.c @@ -54,6 +54,8 @@ void DBclose(void) #endif } +static int have_db_err = 0; + /* * Connect to the database. * If fails, program terminates. @@ -66,27 +68,31 @@ void DBconnect(void) #ifdef HAVE_MYSQL /* For MySQL >3.22.00 */ /* if( ! mysql_connect( &mysql, NULL, dbuser, dbpassword ) )*/ + mysql_init(&mysql); - if( ! mysql_real_connect( &mysql, CONFIG_DBHOST, CONFIG_DBUSER, CONFIG_DBPASSWORD, CONFIG_DBNAME, CONFIG_DBPORT, CONFIG_DBSOCKET,0 ) ) + + if( ! mysql_real_connect( &mysql, CONFIG_DBHOST, CONFIG_DBUSER, CONFIG_DBPASSWORD, CONFIG_DBNAME, CONFIG_DBPORT, CONFIG_DBSOCKET,0 ) ) { - fprintf(stderr, "Failed to connect to database: Error: %s\n",mysql_error(&mysql) ); - zabbix_log(LOG_LEVEL_ERR, "Failed to connect to database: Error: %s",mysql_error(&mysql) ); - if( (ER_SERVER_SHUTDOWN != mysql_errno(&mysql)) && (CR_SERVER_GONE_ERROR != mysql_errno(&mysql))) - { - exit(FAIL); - } + /* Don't print the log message EVERY loop */ + if ( ! have_db_err) + { + zabbix_log(LOG_LEVEL_ERR, "Failed to connect to database: Error: %s",mysql_error(&mysql) ); + zabbix_log(LOG_LEVEL_ERR, "Will retry to connect to the database every 30 seconds"); + have_db_err = 1; + } } else { - if( mysql_select_db( &mysql, CONFIG_DBNAME ) != 0 ) + mysql.reconnect = 1; + if( mysql_select_db( &mysql, CONFIG_DBNAME ) != 0 ) { - fprintf(stderr, "Failed to select database: Error: %s\n",mysql_error(&mysql) ); zabbix_log(LOG_LEVEL_ERR, "Failed to select database: Error: %s",mysql_error(&mysql) ); exit( FAIL ); } else { + have_db_err = 0; break; } } @@ -97,21 +103,19 @@ void DBconnect(void) conn = PQsetdbLogin(CONFIG_DBHOST, NULL, NULL, NULL, CONFIG_DBNAME, CONFIG_DBUSER, CONFIG_DBPASSWORD ); /* check to see that the backend connection was successfully made */ - if (PQstatus(conn) != CONNECTION_OK) + if (PQstatus(conn) != CONNECTION_OK && !have_db_err) { - fprintf(stderr, "Connection to database '%s' failed.\n", CONFIG_DBNAME); zabbix_log(LOG_LEVEL_ERR, "Connection to database '%s' failed.\n", CONFIG_DBNAME); - fprintf(stderr, "%s\n", PQerrorMessage(conn)); zabbix_log(LOG_LEVEL_ERR, "%s", PQerrorMessage(conn)); - exit(FAIL); + zabbix_log(LOG_LEVEL_ERR, "Will retry to connect to the database every 30 seconds"); + have_db_err = 1; } else { + have_db_err = 0; break; } #endif - fprintf(stderr, "Will retry to connect to the database after 30 seconds\n"); - zabbix_log(LOG_LEVEL_ERR, "Will retry to connect to the database after 30 seconds"); sleep(30); } } @@ -125,15 +129,21 @@ int DBexecute(char *query) /* Do not include any code here. Will break HAVE_PGSQL section */ #ifdef HAVE_MYSQL zabbix_log( LOG_LEVEL_DEBUG, "Executing query:%s",query); + while( mysql_query(&mysql,query) != 0) { zabbix_log( LOG_LEVEL_ERR, "Query::%s",query); zabbix_log(LOG_LEVEL_ERR, "Query failed:%s [%d]", mysql_error(&mysql), mysql_errno(&mysql) ); - if( (ER_SERVER_SHUTDOWN != mysql_errno(&mysql)) && (CR_SERVER_GONE_ERROR != mysql_errno(&mysql))) + + if( (ER_SERVER_SHUTDOWN != mysql_errno(&mysql)) && + (CR_SERVER_GONE_ERROR != mysql_errno(&mysql)) && + (CR_CONNECTION_ERROR != mysql_errno(&mysql))) { return FAIL; } - sleep(30); + + DBclose(); + DBconnect(); } #endif #ifdef HAVE_PGSQL @@ -171,17 +181,23 @@ DB_RESULT *DBselect(char *query) /* Do not include any code here. Will break HAVE_PGSQL section */ #ifdef HAVE_MYSQL zabbix_log( LOG_LEVEL_DEBUG, "Executing query:%s",query); + while(mysql_query(&mysql,query) != 0) { zabbix_log( LOG_LEVEL_ERR, "Query::%s",query); zabbix_log(LOG_LEVEL_ERR, "Query failed:%s [%d]", mysql_error(&mysql), mysql_errno(&mysql) ); - if( (ER_SERVER_SHUTDOWN != mysql_errno(&mysql)) && (CR_SERVER_GONE_ERROR != mysql_errno(&mysql))) + + if( (ER_SERVER_SHUTDOWN != mysql_errno(&mysql)) && + (CR_SERVER_GONE_ERROR != mysql_errno(&mysql)) && + (CR_CONNECTION_ERROR != mysql_errno(&mysql))) { exit(FAIL); } - sleep(30); + + DBclose(); + DBconnect(); } -/* zabbix_set_log_level(LOG_LEVEL_WARNING);*/ + return mysql_store_result(&mysql); #endif #ifdef HAVE_PGSQL diff --git a/src/zabbix_server/housekeeper/housekeeper.c b/src/zabbix_server/housekeeper/housekeeper.c index 0ff0ea07..0217a9d8 100644 --- a/src/zabbix_server/housekeeper/housekeeper.c +++ b/src/zabbix_server/housekeeper/housekeeper.c @@ -105,7 +105,7 @@ static int delete_host(int hostid) int res = 0; zabbix_log(LOG_LEVEL_DEBUG,"In delete_host(%d)", hostid); - snprintf(sql,sizeof(sql)-1,"select itemid from items where hostid=%d", hostid); + snprintf(sql,sizeof(sql)-1,"select itemid from items where hostid=%d and serverid=%d", hostid,CONFIG_SERVERD_ID); result = DBselect(sql); for(i=0;i<DBnum_rows(result);i++) @@ -156,7 +156,7 @@ static int housekeeping_items(void) DB_RESULT *result; int i,itemid; - snprintf(sql,sizeof(sql)-1,"select itemid from items where status=%d", ITEM_STATUS_DELETED); + snprintf(sql,sizeof(sql)-1,"select itemid from items where status=%d and serverid=%d", ITEM_STATUS_DELETED,CONFIG_SERVERD_ID); result = DBselect(sql); for(i=0;i<DBnum_rows(result);i++) { @@ -189,7 +189,7 @@ static int housekeeping_hosts(void) DB_RESULT *result; int i,hostid; - snprintf(sql,sizeof(sql)-1,"select hostid from hosts where status=%d", HOST_STATUS_DELETED); + snprintf(sql,sizeof(sql)-1,"select hostid from hosts where status=%d and serverid=%d", HOST_STATUS_DELETED,CONFIG_SERVERD_ID); result = DBselect(sql); for(i=0;i<DBnum_rows(result);i++) { @@ -225,7 +225,7 @@ static int housekeeping_history_and_trends(int now) int i; - snprintf(sql,sizeof(sql)-1,"select itemid,history,delay,trends from items"); + snprintf(sql,sizeof(sql)-1,"select itemid,history,delay,trends from items, where serverid=%d",CONFIG_SERVERD_ID); result = DBselect(sql); for(i=0;i<DBnum_rows(result);i++) diff --git a/src/zabbix_server/housekeeper/housekeeper.h b/src/zabbix_server/housekeeper/housekeeper.h index 987c23fe..bcd6a772 100644 --- a/src/zabbix_server/housekeeper/housekeeper.h +++ b/src/zabbix_server/housekeeper/housekeeper.h @@ -28,6 +28,7 @@ extern char *CONFIG_DBUSER; extern char *CONFIG_DBPASSWORD; extern char *CONFIG_DBSOCKET; extern char *CONFIG_FPING_LOCATION; +extern int CONFIG_SERVERD_ID; int main_housekeeper_loop(); diff --git a/src/zabbix_server/pinger/pinger.c b/src/zabbix_server/pinger/pinger.c index c3a7708e..c95b5586 100644 --- a/src/zabbix_server/pinger/pinger.c +++ b/src/zabbix_server/pinger/pinger.c @@ -133,11 +133,11 @@ static int process_value(char *key, char *host, char *value) /* IP address? */ if(is_ip(host) == SUCCEED) { - snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.value_type,i.trapper_hosts,i.delta,i.units,i.multiplier,i.formula from items i,hosts h where h.status=%d and h.hostid=i.hostid and h.ip='%s' and i.key_='%s' and i.status=%d and i.type=%d", HOST_STATUS_MONITORED, host, key, ITEM_STATUS_ACTIVE, ITEM_TYPE_SIMPLE); + snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.value_type,i.trapper_hosts,i.delta,i.units,i.multiplier,i.formula from items i,hosts h where h.status=%d and h.hostid=i.hostid and h.ip='%s' and i.key_='%s' and i.status=%d and i.type=%d and i.serverid=%d", HOST_STATUS_MONITORED, host, key, ITEM_STATUS_ACTIVE, ITEM_TYPE_SIMPLE,CONFIG_SERVERD_ID); } else { - snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.value_type,i.trapper_hosts,i.delta,i.units,i.multiplier,i.formula from items i,hosts h where h.status=%d and h.hostid=i.hostid and h.host='%s' and i.key_='%s' and i.status=%d and i.type=%d", HOST_STATUS_MONITORED, host, key, ITEM_STATUS_ACTIVE, ITEM_TYPE_SIMPLE); + snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.value_type,i.trapper_hosts,i.delta,i.units,i.multiplier,i.formula from items i,hosts h where h.status=%d and h.hostid=i.hostid and h.host='%s' and i.key_='%s' and i.status=%d and i.type=%d and i.serverid=%d", HOST_STATUS_MONITORED, host, key, ITEM_STATUS_ACTIVE, ITEM_TYPE_SIMPLE,CONFIG_SERVERD_ID); } zabbix_log( LOG_LEVEL_DEBUG, "SQL [%s]", sql); result = DBselect(sql); @@ -237,7 +237,7 @@ static int create_host_file(void) now=time(NULL); /* Select hosts monitored by IP */ - snprintf(sql,sizeof(sql)-1,"select distinct h.ip from hosts h,items i where i.hostid=h.hostid and (h.status=%d or (h.status=%d and h.available=%d and h.disable_until<=%d)) and (i.key_='%s' or i.key_='%s') and i.type=%d and i.status=%d and h.useip=1", HOST_STATUS_MONITORED, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY, ITEM_TYPE_SIMPLE, ITEM_STATUS_ACTIVE); + snprintf(sql,sizeof(sql)-1,"select distinct h.ip from hosts h,items i where i.hostid=h.hostid and (h.status=%d or (h.status=%d and h.available=%d and h.disable_until<=%d)) and (i.key_='%s' or i.key_='%s') and i.type=%d and i.status=%d and h.useip=1 and i.serverid=%d", HOST_STATUS_MONITORED, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY, ITEM_TYPE_SIMPLE, ITEM_STATUS_ACTIVE,CONFIG_SERVERD_ID); result = DBselect(sql); for(i=0;i<DBnum_rows(result);i++) @@ -252,7 +252,7 @@ static int create_host_file(void) DBfree_result(result); /* Select hosts monitored by hostname */ - snprintf(sql,sizeof(sql)-1,"select distinct h.host from hosts h,items i where i.hostid=h.hostid and (h.status=%d or (h.status=%d and h.available=%d and h.disable_until<=%d)) and (i.key_='%s' or i.key_='%s') and i.type=%d and i.status=%d and h.useip=0", HOST_STATUS_MONITORED, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY, ITEM_TYPE_SIMPLE, ITEM_STATUS_ACTIVE); + snprintf(sql,sizeof(sql)-1,"select distinct h.host from hosts h,items i where i.hostid=h.hostid and (h.status=%d or (h.status=%d and h.available=%d and h.disable_until<=%d)) and (i.key_='%s' or i.key_='%s') and i.type=%d and i.status=%d and h.useip=0 and i.serverid=%d", HOST_STATUS_MONITORED, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY, ITEM_TYPE_SIMPLE, ITEM_STATUS_ACTIVE,CONFIG_SERVERD_ID); result = DBselect(sql); for(i=0;i<DBnum_rows(result);i++) diff --git a/src/zabbix_server/pinger/pinger.h b/src/zabbix_server/pinger/pinger.h index e4f1d08d..70fe0935 100644 --- a/src/zabbix_server/pinger/pinger.h +++ b/src/zabbix_server/pinger/pinger.h @@ -28,6 +28,7 @@ extern char *CONFIG_DBUSER; extern char *CONFIG_DBPASSWORD; extern char *CONFIG_DBSOCKET; extern char *CONFIG_FPING_LOCATION; +extern int CONFIG_SERVERD_ID; extern void signal_handler( int sig ); diff --git a/src/zabbix_server/poller/poller.c b/src/zabbix_server/poller/poller.c index 64b2e809..bc806dd3 100644 --- a/src/zabbix_server/poller/poller.c +++ b/src/zabbix_server/poller/poller.c @@ -110,7 +110,7 @@ static int get_minnextcheck(int now) /* Host status 0 == MONITORED 1 == NOT MONITORED 2 == UNREACHABLE */ - snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<%d)) and h.hostid=i.hostid and i.status=%d and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s')", HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE,HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); + snprintf(sql,sizeof(sql)-1,"select count(*),min(nextcheck) from items i,hosts h where ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<%d)) and h.hostid=i.hostid and i.status=%d and i.type not in (%d,%d) and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') and i.serverid=%d", HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE,HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY,CONFIG_SERVERD_ID); result = DBselect(sql); if( DBnum_rows(result) == 0) @@ -145,7 +145,7 @@ static void update_key_status(int hostid,int host_status) zabbix_log(LOG_LEVEL_DEBUG, "In update_key_status()"); - snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available from items i,hosts h where h.hostid=i.hostid and h.hostid=%d and i.key_='%s'", hostid,SERVER_STATUS_KEY); + snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available from items i,hosts h where h.hostid=i.hostid and h.hostid=%d and i.key_='%s' and i.serverid=%d", hostid,SERVER_STATUS_KEY,CONFIG_SERVERD_ID); result = DBselect(sql); if( DBnum_rows(result) == 0) @@ -184,7 +184,7 @@ int get_values(void) now = time(NULL); - snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available from items i,hosts h where i.nextcheck<=%d and i.status=%d and i.type not in (%d,%d) and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<=%d)) and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') order by i.nextcheck", now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY); + snprintf(sql,sizeof(sql)-1,"select i.itemid,i.key_,h.host,h.port,i.delay,i.description,i.nextcheck,i.type,i.snmp_community,i.snmp_oid,h.useip,h.ip,i.history,i.lastvalue,i.prevvalue,i.hostid,h.status,i.value_type,h.network_errors,i.snmp_port,i.delta,i.prevorgvalue,i.lastclock,i.units,i.multiplier,i.snmpv3_securityname,i.snmpv3_securitylevel,i.snmpv3_authpassphrase,i.snmpv3_privpassphrase,i.formula,h.available from items i,hosts h where i.nextcheck<=%d and i.status=%d and i.type not in (%d,%d) and ((h.status=%d and h.available!=%d) or (h.status=%d and h.available=%d and h.disable_until<=%d)) and h.hostid=i.hostid and i.itemid%%%d=%d and i.key_ not in ('%s','%s','%s','%s') and i.serverid=%d order by i.nextcheck", now, ITEM_STATUS_ACTIVE, ITEM_TYPE_TRAPPER, ITEM_TYPE_ZABBIX_ACTIVE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, HOST_STATUS_MONITORED, HOST_AVAILABLE_FALSE, now, CONFIG_SUCKERD_FORKS-5,server_num-5,SERVER_STATUS_KEY, SERVER_ICMPPING_KEY, SERVER_ICMPPINGSEC_KEY,SERVER_ZABBIXLOG_KEY,CONFIG_SERVERD_ID); result = DBselect(sql); for(i=0;i<DBnum_rows(result);i++) diff --git a/src/zabbix_server/poller/poller.h b/src/zabbix_server/poller/poller.h index 5b39602a..d5c6a18e 100644 --- a/src/zabbix_server/poller/poller.h +++ b/src/zabbix_server/poller/poller.h @@ -24,6 +24,7 @@ extern void signal_handler(int); extern int server_num; extern int CONFIG_TIMEOUT; +extern int CONFIG_SERVERD_ID; extern int CONFIG_SUCKERD_FORKS; void main_poller_loop(); diff --git a/src/zabbix_server/server.c b/src/zabbix_server/server.c index 1885effb..123ebd35 100644 --- a/src/zabbix_server/server.c +++ b/src/zabbix_server/server.c @@ -66,6 +66,7 @@ pid_t *pids=NULL; int server_num=0; +int CONFIG_SERVERD_ID =SERVERD_ID; int CONFIG_SUCKERD_FORKS =SUCKER_FORKS; /* For trapper */ int CONFIG_TRAPPERD_FORKS = TRAPPERD_FORKS; @@ -304,6 +305,7 @@ void init_config(void) static struct cfg_line cfg[]= { /* PARAMETER ,VAR ,FUNC, TYPE(0i,1s),MANDATORY,MIN,MAX */ + {"Server",&CONFIG_SERVERD_ID,0,TYPE_INT,PARM_OPT,1,255}, {"StartSuckers",&CONFIG_SUCKERD_FORKS,0,TYPE_INT,PARM_OPT,6,255}, {"HousekeepingFrequency",&CONFIG_HOUSEKEEPING_FREQUENCY,0,TYPE_INT,PARM_OPT,1,24}, {"SenderFrequency",&CONFIG_SENDER_FREQUENCY,0,TYPE_INT,PARM_OPT,5,3600}, diff --git a/src/zabbix_server/timer/timer.c b/src/zabbix_server/timer/timer.c index 1f8735c2..a73cb6e3 100644 --- a/src/zabbix_server/timer/timer.c +++ b/src/zabbix_server/timer/timer.c @@ -45,6 +45,8 @@ extern void update_triggers(int itemid); +extern int CONFIG_SERVERD_ID; + /****************************************************************************** * * * Function: main_timer_loop * @@ -81,9 +83,9 @@ void main_timer_loop() now=time(NULL); #ifdef HAVE_PGSQL - snprintf(sql,sizeof(sql)-1,"select distinct f.itemid,f.functionid,f.parameter from functions f, items i,hosts h where h.hostid=i.hostid and h.status=%d and i.itemid=f.itemid and f.function in ('nodata','date','dayofweek','time','now') and i.lastclock+f.parameter::text::integer<=%d and i.status=%d", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE); + snprintf(sql,sizeof(sql)-1,"select distinct f.itemid,f.functionid,f.parameter from functions f, items i,hosts h where h.hostid=i.hostid and h.status=%d and i.itemid=f.itemid and f.function in ('nodata','date','dayofweek','time','now') and i.lastclock+f.parameter::text::integer<=%d and i.status=%d and i.serverid=%d", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE,CONFIG_SERVERD_ID); #else - snprintf(sql,sizeof(sql)-1,"select distinct f.itemid,f.functionid,f.parameter,f.function from functions f, items i,hosts h where h.hostid=i.hostid and h.status=%d and i.itemid=f.itemid and f.function in ('nodata','date','dayofweek','time','now') and i.lastclock+f.parameter<=%d and i.status=%d", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE); + snprintf(sql,sizeof(sql)-1,"select distinct f.itemid,f.functionid,f.parameter,f.function from functions f, items i,hosts h where h.hostid=i.hostid and h.status=%d and i.itemid=f.itemid and f.function in ('nodata','date','dayofweek','time','now') and i.lastclock+f.parameter<=%d and i.status=%d and i.serverid=%d", HOST_STATUS_MONITORED, now, ITEM_STATUS_ACTIVE,CONFIG_SERVERD_ID); #endif result = DBselect(sql); diff --git a/src/zabbix_server/timer/timer.h b/src/zabbix_server/timer/timer.h index bcd95c1d..b38c4504 100644 --- a/src/zabbix_server/timer/timer.h +++ b/src/zabbix_server/timer/timer.h @@ -27,6 +27,7 @@ extern int server_num; extern int CONFIG_TIMEOUT; extern int CONFIG_SUCKERD_FORKS; */ +extern int CONFIG_SERVERD_ID; int main_timer_loop(); diff --git a/upgrades/dbpatches/1.1beta2_to_1.1beta3/mysql/patch.sql b/upgrades/dbpatches/1.1beta2_to_1.1beta3/mysql/patch.sql index dd3aae97..0ded8deb 100644 --- a/upgrades/dbpatches/1.1beta2_to_1.1beta3/mysql/patch.sql +++ b/upgrades/dbpatches/1.1beta2_to_1.1beta3/mysql/patch.sql @@ -1 +1,23 @@ alter table users add refresh int(4) DEFAULT '30' NOT NULL; + + +alter table hosts add serverid int(4) DEFAULT '1' NOT NULL AFTER hostid; +alter table hosts add KEY (serverid); + +alter table items add serverid int(4) DEFAULT '1' NOT NULL AFTER hostid; +alter table items add KEY (serverid); + +-- +-- Table structure for table 'servers' +-- + +CREATE TABLE servers ( + serverid int(4) NOT NULL auto_increment, + host varchar(64) DEFAULT '' NOT NULL, + ip varchar(15) DEFAULT '127.0.0.1' NOT NULL, + port int(4) DEFAULT '0' NOT NULL, + PRIMARY KEY (serverid), + UNIQUE (host) +) type=InnoDB; +insert into servers values(1,'DEFAULT','127.0.0.1',10051); + diff --git a/upgrades/dbpatches/1.1beta2_to_1.1beta3/postgresql/patch.sql b/upgrades/dbpatches/1.1beta2_to_1.1beta3/postgresql/patch.sql index 463874be..54fe26aa 100644 --- a/upgrades/dbpatches/1.1beta2_to_1.1beta3/postgresql/patch.sql +++ b/upgrades/dbpatches/1.1beta2_to_1.1beta3/postgresql/patch.sql @@ -1 +1,23 @@ alter table users add refresh int4 DEFAULT '30' NOT NULL; + + +alter table hosts add serverid int4 DEFAULT '1' NOT NULL AFTER hostid; +alter table hosts add INDEX hosts_server on hosts (serverid); + +alter table items add serverid int4 DEFAULT '1' NOT NULL AFTER hostid; +alter table items add INDEX items_server on items (serverid); + +-- +-- Table structure for table 'servers' +-- + +CREATE TABLE servers ( + serverid serial + host varchar(64) DEFAULT '' NOT NULL, + ip varchar(15) DEFAULT '127.0.0.1' NOT NULL, + port int4 DEFAULT '0' NOT NULL, + PRIMARY KEY (serverid), + PRIMARY KEY (serverid) +); +insert into servers values(1,'DEFAULT','127.0.0.1',10051); + |