From b08a351860b379d09344887a4aa572be736be9b5 Mon Sep 17 00:00:00 2001 From: james_wells Date: Sat, 5 Nov 2005 03:28:01 +0000 Subject: 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 --- ChangeLog | 2 + create/mysql/schema.sql | 13 ++++ create/postgresql/schema.sql | 19 +++++ frontends/php/include/config.inc.php | 3 +- frontends/php/include/forms.inc.php | 84 +++++++++++++++++++++- frontends/php/include/items.inc.php | 20 +++--- frontends/php/include/locales/de_de.inc.php | 2 + frontends/php/include/locales/en_gb.inc.php | 9 +++ frontends/php/include/locales/fr_fr.inc.php | 2 + frontends/php/include/locales/it_it.inc.php | 2 + frontends/php/include/locales/lv_lv.inc.php | 2 + frontends/php/include/locales/ru_ru.inc.php | 2 + frontends/php/include/locales/sp_sp.inc.php | 2 + frontends/php/items.php | 48 +++++++++++-- go | 10 +-- include/common.h | 12 +++- misc/conf/zabbix_server.conf | 5 ++ src/libs/zbxdbhigh/db.c | 56 +++++++++------ src/zabbix_server/housekeeper/housekeeper.c | 8 +-- src/zabbix_server/housekeeper/housekeeper.h | 1 + src/zabbix_server/pinger/pinger.c | 8 +-- src/zabbix_server/pinger/pinger.h | 1 + src/zabbix_server/poller/poller.c | 6 +- src/zabbix_server/poller/poller.h | 1 + src/zabbix_server/server.c | 2 + src/zabbix_server/timer/timer.c | 6 +- src/zabbix_server/timer/timer.h | 1 + .../dbpatches/1.1beta2_to_1.1beta3/mysql/patch.sql | 22 ++++++ .../1.1beta2_to_1.1beta3/postgresql/patch.sql | 22 ++++++ 29 files changed, 313 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1f280add..673a705f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 ""; ), "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 ""; 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 ""; + $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 ""; + } + else + { + echo ""; + } + 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 "
"; + + echo S_SERVER_HOST; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo S_SERVER_IP; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter($col++); + echo S_SERVER_PORT; + show_table2_h_delimiter(); + echo ""; + + show_table2_v_delimiter2(); + if($serverid==0) + { + echo ""; + } + else + { + echo ""; + } + echo ""; + 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 @@ '$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 @@ ?> $row["host"]); + } + if(!check_anyright("Host","U")) { show_table_header("".S_NO_PERMISSIONS.""; echo ""; - $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(); diff --git a/go b/go index 3086b870..398448fa 100755 --- a/go +++ b/go @@ -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