summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/nodes.inc.php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-10-25 07:21:56 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-10-25 07:21:56 +0000
commitd23332dbc5dabb29dfec400d2d9ba782b46b5615 (patch)
tree21d5823c2940c9ada032bc3650fac8423b266365 /frontends/php/include/nodes.inc.php
parent28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89 (diff)
downloadzabbix-d23332dbc5dabb29dfec400d2d9ba782b46b5615.tar.gz
zabbix-d23332dbc5dabb29dfec400d2d9ba782b46b5615.tar.xz
zabbix-d23332dbc5dabb29dfec400d2d9ba782b46b5615.zip
- developed node manager (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3379 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/nodes.inc.php')
-rw-r--r--frontends/php/include/nodes.inc.php72
1 files changed, 72 insertions, 0 deletions
diff --git a/frontends/php/include/nodes.inc.php b/frontends/php/include/nodes.inc.php
new file mode 100644
index 00000000..306c66df
--- /dev/null
+++ b/frontends/php/include/nodes.inc.php
@@ -0,0 +1,72 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+ require_once "include/db.inc.php";
+?>
+<?php
+ function add_node($name,$timezone,$ip,$port,$slave_history,$slave_trends)
+ {
+ global $ZBX_CURNODEID;
+
+ $nodeid = DBfetch(DBselect('select max(nodeid) as max from nodes'));
+ $nodeid = $nodeid['max'] + 1;
+ $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.','.
+ '0,0,0,'.$ZBX_CURNODEID.')');
+
+ return ($result ? $nodeid : $result);
+ }
+
+ function update_node($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.','.
+ 'slave_history='.$slave_history.',slave_trends='.$slave_trends.
+ ' where nodeid='.$nodeid);
+ return $result;
+ }
+
+ function delete_node($nodeid)
+ {
+ $result = false;
+ if(!DBfetch(DBselect('select * from nodes where masterid='.$nodeid)))
+ {
+ $result = DBexecute('delete from nodes where nodeid='.$nodeid);
+ }
+ return $result;
+ }
+
+ function get_node_by_nodeid($nodeid)
+ {
+ return DBfetch(DBselect('select * from nodes where nodeid='.$nodeid));
+ }
+
+ function get_node_path($nodeid, $result='/')
+ {
+ if($node_data = get_node_by_nodeid($nodeid))
+ {
+ if($node_data['masterid'])
+ {
+ $result = get_node_path($node_data['masterid'],$result);
+ }
+ $result .= $node_data['name'].'/';
+ }
+ return $result;
+ }
+?>