From a3ee144e22596c3aea1fab644ed4c93e4466608a Mon Sep 17 00:00:00 2001 From: sasha Date: Fri, 5 Oct 2007 08:43:57 +0000 Subject: - [ZBX-92] Distributed monitoring: overwriting new information [svn merge svn://svn.zabbix.com/branches/1.4 -r4832:4836] git-svn-id: svn://svn.zabbix.com/trunk@4837 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/include/db.inc.php | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'frontends/php/include/db.inc.php') diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 4e82d072..6ca848d2 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -538,17 +538,13 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") { $found = false; do { - $row = DBfetch(DBselect('select nextid from ids '. - ' where nodeid='.$nodeid. - ' and table_name=\''.$table.'\' '. - ' and field_name=\''.$field.'\'')); + global $ZBX_LOCALNODEID; - if(!$row || is_null($row["nextid"])) + $min=bcadd(bcmul($nodeid,"100000000000000"),bcmul($ZBX_LOCALNODEID,"100000000000")); + $max=bcadd(bcadd(bcmul($nodeid,"100000000000000"),bcmul($ZBX_LOCALNODEID,"100000000000")),"99999999999"); + $row = DBfetch(DBselect("select nextid from ids where nodeid=$nodeid and table_name='$table' and field_name='$field'")); + if(!$row) { - global $ZBX_LOCALNODEID; - - $min=bcadd(bcmul($nodeid,"100000000000000"),bcmul($ZBX_LOCALNODEID,"100000000000")); - $max=bcadd(bcadd(bcmul($nodeid,"100000000000000"),bcmul($ZBX_LOCALNODEID,"100000000000")),"99999999999"); $row=DBfetch(DBselect("select max($field) as id from $table where $field>=$min and $field<=$max")); if(!$row || is_null($row["id"])) { @@ -557,6 +553,13 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") { } else { + /* + $ret1 = $row["id"]; + if($ret1 >= $max) { + "Maximum number of id's was exceeded" + } + */ + DBexecute("insert into ids (nodeid,table_name,field_name,nextid) values ($nodeid,'$table','$field',".$row["id"].")"); } continue; @@ -564,6 +567,10 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") { else { $ret1 = $row["nextid"]; + if(($ret1 < $min) || ($ret1 >= $max)) { + DBexecute("delete from ids where nodeid=$nodeid and table_name='$table' and field_name='$field'"); + continue; + } DBexecute("update ids set nextid=nextid+1 where nodeid=$nodeid and table_name='$table' and field_name='$field'"); -- cgit