1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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;
}
?>
|