- Added component locks
[public/netxms.git] / sql / schema.in
CommitLineData
6c9e7d36
VK
1/*
2** System configuration table
3*/
cbcaf8c8 4
49826a80 5CREATE TABLE Config
cbcaf8c8 6(
9e6c6d05
VK
7 name varchar(64) not null,
8 value varchar(255),
9 PRIMARY KEY(name)
cbcaf8c8
VK
10);
11
12
6c9e7d36
VK
13/*
14** Users
15*/
9b057805
VK
16
17CREATE TABLE Users
18(
19 id integer not null,
20 name varchar(64) not null,
4c57296d 21 password varchar(48),
f806ed94 22 access integer,
9b057805
VK
23 PRIMARY KEY(id)
24);
25
26
6c9e7d36
VK
27/*
28** User groups
29*/
f806ed94
VK
30
31CREATE TABLE UserGroups
32(
33 id integer not null,
34 name varchar(64) not null,
35 access integer,
36 PRIMARY KEY(id)
37);
38
39
6c9e7d36
VK
40/*
41** Users to groups mapping
42*/
f806ed94
VK
43
44CREATE TABLE UserGroupMembers
45(
46 group_id integer not null,
47 user_id integer not null,
77f69c9d 48#ifdef DB_MYSQL
f806ed94 49 KEY(group_id)
77f69c9d 50#endif
f806ed94
VK
51);
52
53
6c9e7d36
VK
54/*
55** Nodes to be added
56*/
49826a80
VK
57
58CREATE TABLE NewNodes
59(
60 id integer not null,
61 ip_addr integer not null,
62 ip_netmask integer not null,
63 discovery_flags integer not null
64);
65
66
6c9e7d36
VK
67/*
68** Nodes information
69*/
cbcaf8c8 70
49826a80 71CREATE TABLE Nodes
cbcaf8c8 72(
9e6c6d05 73 id integer not null,
cbcaf8c8
VK
74 name varchar(64),
75 status integer,
49826a80 76 is_deleted integer not null,
cbcaf8c8 77 primary_ip integer,
49826a80
VK
78 is_snmp integer,
79 is_agent integer,
80 is_bridge integer,
81 is_router integer,
83f01fdf 82 is_local_mgmt integer,
49826a80 83 snmp_version integer,
a713e82e 84 community varchar(32),
e5c63a9b 85 snmp_oid varchar(255),
49826a80 86 discovery_flags integer,
a713e82e
VK
87 auth_method integer,
88 secret varchar(64),
89 agent_port integer,
90 status_poll_type integer,
f806ed94 91 inherit_access_rights integer,
9e6c6d05
VK
92 PRIMARY KEY(id)
93);
94
95
6c9e7d36
VK
96/*
97** Subnets
98*/
cbcaf8c8 99
49826a80 100CREATE TABLE Subnets
cbcaf8c8 101(
9e6c6d05 102 id integer not null,
cbcaf8c8
VK
103 name varchar(64),
104 status integer,
49826a80 105 is_deleted integer not null,
cbcaf8c8 106 ip_addr integer,
9e6c6d05
VK
107 ip_netmask integer,
108 PRIMARY KEY(id)
cbcaf8c8
VK
109);
110
111
6c9e7d36
VK
112/*
113** Nodes' interfaces
114*/
cbcaf8c8 115
a713e82e 116CREATE TABLE Interfaces
cbcaf8c8 117(
9e6c6d05 118 id integer not null,
cbcaf8c8 119 name varchar(64),
49826a80
VK
120 status integer,
121 is_deleted integer,
122 node_id integer not null,
cbcaf8c8
VK
123 ip_addr integer,
124 ip_netmask integer,
49826a80
VK
125 if_type integer,
126 if_index integer,
127 PRIMARY KEY(id),
77f69c9d 128#ifdef DB_MYSQL
49826a80 129 KEY(node_id)
77f69c9d 130#endif
cbcaf8c8
VK
131);
132
133
6c9e7d36
VK
134/*
135** Nodes to subnets mapping
136*/
cbcaf8c8 137
a713e82e 138CREATE TABLE nsmap
cbcaf8c8 139(
49826a80
VK
140 subnet_id integer not null,
141 node_id integer not null,
77f69c9d 142#ifdef DB_MYSQL
25e01e36 143 KEY (subnet_id)
77f69c9d 144#endif
cbcaf8c8
VK
145);
146
147
6c9e7d36
VK
148/*
149** Objects' ACLs
150*/
f806ed94
VK
151
152CREATE TABLE acl
153(
154 object_id integer not null,
155 user_id integer not null,
156 access_rights integer not null,
77f69c9d 157#ifdef DB_MYSQL
f806ed94 158 KEY(object_id)
77f69c9d 159#endif
f806ed94
VK
160);
161
162
6c9e7d36
VK
163/*
164** Data collection items
165*/
cbcaf8c8 166
b2581e52 167CREATE TABLE Items
cbcaf8c8 168(
9e6c6d05 169 id integer not null,
b2581e52 170 node_id integer not null,
cbcaf8c8
VK
171 name varchar(255),
172 description varchar(255),
6c9e7d36 173 source integer, // 0 for internal or 1 for native agent or 2 for SNMP
cbcaf8c8
VK
174 datatype integer,
175 polling_interval integer,
b2581e52
VK
176 retention_time integer,
177 PRIMARY KEY(id),
77f69c9d 178#ifdef DB_MYSQL
b2581e52 179 KEY(node_id)
77f69c9d 180#endif
cbcaf8c8
VK
181);
182
183
6c9e7d36
VK
184/*
185** Events configuration
186*/
cbcaf8c8 187
b36b6578 188CREATE TABLE Events
cbcaf8c8 189(
9e6c6d05 190 id integer not null,
cbcaf8c8 191 severity integer,
c1142e46 192 flags integer,
6c9e7d36
VK
193 message varchar(255), // Message template
194 description DT_TEXT,
b36b6578 195 PRIMARY KEY(id)
cbcaf8c8
VK
196);
197
198
6c9e7d36
VK
199/*
200** Event log
201*/
cbcaf8c8 202
c1142e46 203CREATE TABLE EventLog
cbcaf8c8
VK
204(
205 event_id integer,
206 timestamp integer,
6c9e7d36 207 source integer, // Source object ID
cbcaf8c8 208 severity integer,
c1142e46 209 message varchar(255),
77f69c9d 210#ifdef DB_MYSQL
c1142e46
VK
211 KEY(event_id),
212 KEY(timestamp)
77f69c9d 213#endif
cbcaf8c8
VK
214);
215
216
6c9e7d36
VK
217/*
218** Actions on events
219*/
cbcaf8c8 220
9e6c6d05 221CREATE TABLE ACTIONS
cbcaf8c8 222(
9e6c6d05 223 id integer not null,
cbcaf8c8 224 type integer,
9e6c6d05
VK
225 command varchar(255),
226 PRIMARY KEY(id)
cbcaf8c8 227);
69cc295f
VK
228
229
6c9e7d36
VK
230/*
231** Node groups
232*/
69cc295f
VK
233
234CREATE TABLE NodeGroups
235(
236 id integer not null,
237 name varchar(255),
238 PRIMARY KEY(id)
239);
240
241
6c9e7d36
VK
242/*
243** Event groups
244*/
69cc295f
VK
245
246CREATE TABLE EventGroups
247(
248 id integer not null,
249 name varchar(255),
250 PRIMARY KEY(id)
251);
252
253
6c9e7d36
VK
254/*
255** Node group members
256*/
69cc295f
VK
257
258CREATE TABLE NodeGroupMembers
259(
260 group_id integer not null,
261 node_id integer not null,
77f69c9d 262#ifdef DB_MYSQL
69cc295f
VK
263 KEY(group_id),
264 KEY(node_id)
77f69c9d 265#endif
69cc295f
VK
266);
267
268
6c9e7d36
VK
269/*
270** Event group members
271*/
69cc295f
VK
272
273CREATE TABLE EventGroupMembers
274(
275 group_id integer not null,
276 event_id integer not null,
77f69c9d 277#ifdef DB_MYSQL
69cc295f
VK
278 KEY(group_id),
279 KEY(event_id)
77f69c9d 280#endif
69cc295f
VK
281);
282
283
6c9e7d36
VK
284/*
285** Event processing policy
286*/
69cc295f
VK
287
288CREATE TABLE EventPolicy
289(
6c9e7d36 290 id integer not null, // Rule number
69cc295f
VK
291 comments varchar(255),
292 PRIMARY KEY(id)
293);
294
295CREATE TABLE PolicySourceList
296(
297 rule_id integer not null,
298 source_type integer not null,
299 object_id integer not null,
77f69c9d 300#ifdef DB_MYSQL
69cc295f 301 KEY(rule_id)
77f69c9d 302#endif
69cc295f
VK
303);
304
305CREATE TABLE PolicyEventList
306(
307 rule_id integer not null,
308 is_group integer not null,
309 event_id integer not null,
77f69c9d 310#ifdef DB_MYSQL
69cc295f 311 KEY(rule_id)
77f69c9d 312#endif
69cc295f 313);
54f0de5b
VK
314
315
316/*
317** Deleted objects
318*/
319
320CREATE TABLE DeletedObjects
321(
322 object_id integer not null,
323 object_class integer,
324 name varchar(64),
325 ip_addr integer,
326 ip_netmask integer,
327 PRIMARY KEY(object_id)
328);