summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/nodes.inc.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-26 13:58:43 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2007-03-26 13:58:43 +0000
commit7cd552914e890df489dfe4032ed79f0841db96ff (patch)
tree1328738d7483678e378f06e09b6a10b72af70f70 /frontends/php/include/nodes.inc.php
parented5c04a0dce5c31017b9813e8510dd8165353a7a (diff)
downloadzabbix-7cd552914e890df489dfe4032ed79f0841db96ff.tar.gz
zabbix-7cd552914e890df489dfe4032ed79f0841db96ff.tar.xz
zabbix-7cd552914e890df489dfe4032ed79f0841db96ff.zip
- added possibility to add Node with pre-defined NodeID (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3930 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/nodes.inc.php')
-rw-r--r--frontends/php/include/nodes.inc.php23
1 files changed, 14 insertions, 9 deletions
diff --git a/frontends/php/include/nodes.inc.php b/frontends/php/include/nodes.inc.php
index 9c296ca8..967e2421 100644
--- a/frontends/php/include/nodes.inc.php
+++ b/frontends/php/include/nodes.inc.php
@@ -46,7 +46,7 @@
return $result;
}
- function add_node($name,$timezone,$ip,$port,$slave_history,$slave_trends,$node_type)
+ function add_node($new_nodeid,$name,$timezone,$ip,$port,$slave_history,$slave_trends,$node_type)
{
global $ZBX_CURNODEID, $ZBX_CURMASTERID;
@@ -75,25 +75,30 @@
break;
}
- $nodeid = DBfetch(DBselect('select max(nodeid) as max from nodes'));
- $nodeid = $nodeid['max'] + 1;
+ if(DBfetch(DBselect('select nodeid from nodes where nodeid='.$new_nodeid)))
+ {
+ error('Node with same ID already exist.');
+ return false;
+ }
+
$result = DBexecute('insert into nodes (nodeid,name,timezone,ip,port,slave_history,slave_trends,'.
'event_lastid,history_lastid,nodetype,masterid) values ('.
- $nodeid.','.zbx_dbstr($name).','.$timezone.','.zbx_dbstr($ip).','.$port.','.$slave_history.','.$slave_trends.','.
+ $new_nodeid.','.zbx_dbstr($name).','.$timezone.','.zbx_dbstr($ip).','.$port.','.$slave_history.','.$slave_trends.','.
'0,0,'.$nodetype.','.$masterid.')');
if($result && $node_type == ZBX_NODE_MASTER)
{
- DBexecute('update nodes set masterid='.$nodeid.' where nodeid='.$ZBX_CURNODEID);
- $ZBX_CURMASTERID = $nodeid; /* applay Master node for this script */
+ DBexecute('update nodes set masterid='.$new_nodeid.' where nodeid='.$ZBX_CURNODEID);
+ $ZBX_CURMASTERID = $new_nodeid; /* applay Master node for this script */
}
- return ($result ? $nodeid : $result);
+ return ($result ? $new_nodeid : $result);
}
- function update_node($nodeid,$name,$timezone,$ip,$port,$slave_history,$slave_trends)
+ function update_node($nodeid,$new_nodeid,$name,$timezone,$ip,$port,$slave_history,$slave_trends)
{
- $result = DBexecute('update nodes set name='.zbx_dbstr($name).',timezone='.$timezone.',ip='.zbx_dbstr($ip).',port='.$port.','.
+ $result = DBexecute('update nodes set nodeid='.$new_nodeid.',name='.zbx_dbstr($name).','.
+ 'timezone='.$timezone.',ip='.zbx_dbstr($ip).',port='.$port.','.
'slave_history='.$slave_history.',slave_trends='.$slave_trends.
' where nodeid='.$nodeid);
return $result;