Rule enable/disable function added to policy editor
[public/netxms.git] / sql / schema.in
CommitLineData
6c9e7d36
VK
1/*
2** System configuration table
b51c8c91 3** ex: syntax=sql
6c9e7d36 4*/
cbcaf8c8 5
feea53fd 6CREATE TABLE config
cbcaf8c8 7(
9e6c6d05
VK
8 name varchar(64) not null,
9 value varchar(255),
10 PRIMARY KEY(name)
cbcaf8c8
VK
11);
12
13
b6a77d6d
VK
14/*
15** This table contains information about currently locked tables
16** or subsystems
17*/
18
feea53fd 19CREATE TABLE locks
b6a77d6d
VK
20(
21 component_id integer not null,
22 component_name varchar(64),
23 lock_status integer not null,
24 owner_info varchar(255), // Information about current lock owner, may be empty
25 PRIMARY KEY(component_id)
26);
27
28
6c9e7d36
VK
29/*
30** Users
31*/
9b057805 32
feea53fd 33CREATE TABLE users
9b057805
VK
34(
35 id integer not null,
36 name varchar(64) not null,
4c57296d 37 password varchar(48),
f806ed94 38 access integer,
057f9dfb 39 flags integer,
00c79c7b
VK
40 full_name varchar(127),
41 description varchar(255),
9b057805
VK
42 PRIMARY KEY(id)
43);
44
45
6c9e7d36
VK
46/*
47** User groups
48*/
f806ed94 49
feea53fd 50CREATE TABLE user_groups
f806ed94
VK
51(
52 id integer not null,
53 name varchar(64) not null,
54 access integer,
057f9dfb 55 flags integer,
00c79c7b 56 description varchar(255),
f806ed94
VK
57 PRIMARY KEY(id)
58);
59
60
6c9e7d36
VK
61/*
62** Users to groups mapping
63*/
f806ed94 64
feea53fd 65CREATE TABLE user_group_members
f806ed94
VK
66(
67 group_id integer not null,
68 user_id integer not null,
057f9dfb 69 PRIMARY KEY(group_id,user_id)
f806ed94
VK
70);
71
72
6c9e7d36
VK
73/*
74** Nodes to be added
75*/
49826a80 76
feea53fd 77CREATE TABLE new_nodes
49826a80
VK
78(
79 id integer not null,
80 ip_addr integer not null,
81 ip_netmask integer not null,
82 discovery_flags integer not null
83);
84
85
6c9e7d36
VK
86/*
87** Nodes information
88*/
cbcaf8c8 89
feea53fd 90CREATE TABLE nodes
cbcaf8c8 91(
9e6c6d05 92 id integer not null,
cbcaf8c8
VK
93 name varchar(64),
94 status integer,
49826a80 95 is_deleted integer not null,
cbcaf8c8 96 primary_ip integer,
49826a80
VK
97 is_snmp integer,
98 is_agent integer,
99 is_bridge integer,
100 is_router integer,
83f01fdf 101 is_local_mgmt integer,
49826a80 102 snmp_version integer,
a713e82e 103 community varchar(32),
e5c63a9b 104 snmp_oid varchar(255),
49826a80 105 discovery_flags integer,
a713e82e
VK
106 auth_method integer,
107 secret varchar(64),
108 agent_port integer,
109 status_poll_type integer,
f806ed94 110 inherit_access_rights integer,
9e6c6d05
VK
111 PRIMARY KEY(id)
112);
113
114
6c9e7d36
VK
115/*
116** Subnets
117*/
cbcaf8c8 118
feea53fd 119CREATE TABLE subnets
cbcaf8c8 120(
9e6c6d05 121 id integer not null,
cbcaf8c8
VK
122 name varchar(64),
123 status integer,
49826a80 124 is_deleted integer not null,
cbcaf8c8 125 ip_addr integer,
9e6c6d05
VK
126 ip_netmask integer,
127 PRIMARY KEY(id)
cbcaf8c8
VK
128);
129
130
6c9e7d36
VK
131/*
132** Nodes' interfaces
133*/
cbcaf8c8 134
feea53fd 135CREATE TABLE interfaces
cbcaf8c8 136(
9e6c6d05 137 id integer not null,
cbcaf8c8 138 name varchar(64),
49826a80
VK
139 status integer,
140 is_deleted integer,
141 node_id integer not null,
cbcaf8c8
VK
142 ip_addr integer,
143 ip_netmask integer,
49826a80
VK
144 if_type integer,
145 if_index integer,
b51c8c91 146 PRIMARY KEY(id)
cbcaf8c8
VK
147);
148
149
6c9e7d36
VK
150/*
151** Nodes to subnets mapping
152*/
cbcaf8c8 153
a713e82e 154CREATE TABLE nsmap
cbcaf8c8 155(
49826a80
VK
156 subnet_id integer not null,
157 node_id integer not null,
c98d2ec7 158 PRIMARY KEY(subnet_id,node_id)
cbcaf8c8
VK
159);
160
161
6c9e7d36
VK
162/*
163** Objects' ACLs
164*/
f806ed94 165
feea53fd 166CREATE TABLE acl
f806ed94
VK
167(
168 object_id integer not null,
169 user_id integer not null,
170 access_rights integer not null,
c98d2ec7 171 PRIMARY KEY(object_id,user_id)
f806ed94
VK
172);
173
174
6c9e7d36
VK
175/*
176** Data collection items
177*/
cbcaf8c8 178
feea53fd 179CREATE TABLE items
cbcaf8c8 180(
2fa71464 181 item_id integer not null,
b2581e52 182 node_id integer not null,
2fa71464 183 name varchar(255) not null,
cbcaf8c8 184 description varchar(255),
6c9e7d36 185 source integer, // 0 for internal or 1 for native agent or 2 for SNMP
cbcaf8c8
VK
186 datatype integer,
187 polling_interval integer,
b2581e52 188 retention_time integer,
2fa71464 189 status integer, // ACTIVE, DISABLED or NOT_SUPPORTED
c98d2ec7 190 PRIMARY KEY(item_id)
cbcaf8c8
VK
191);
192
193
6c9e7d36
VK
194/*
195** Events configuration
196*/
cbcaf8c8 197
feea53fd 198CREATE TABLE events
cbcaf8c8 199(
59f88625 200 event_id integer not null,
3c468b80 201 name varchar(64) not null, // Short event name
cbcaf8c8 202 severity integer,
c1142e46 203 flags integer,
6c9e7d36
VK
204 message varchar(255), // Message template
205 description DT_TEXT,
c98d2ec7 206 PRIMARY KEY(event_id)
cbcaf8c8
VK
207);
208
209
6c9e7d36
VK
210/*
211** Event log
212*/
cbcaf8c8 213
feea53fd 214CREATE TABLE event_log
cbcaf8c8
VK
215(
216 event_id integer,
217 timestamp integer,
6c9e7d36 218 source integer, // Source object ID
cbcaf8c8 219 severity integer,
c98d2ec7 220 message varchar(255)
cbcaf8c8
VK
221);
222
223
6c9e7d36
VK
224/*
225** Actions on events
226*/
cbcaf8c8 227
feea53fd 228CREATE TABLE actions
cbcaf8c8 229(
b03374f5 230 action_id integer not null,
b6a77d6d
VK
231 action_type integer,
232 email_addr varchar(255),
233 email_subject varchar(255),
234 // Field "action_data" holds message text for e-mail actions or
235 // command line for external command execution actions
236 action_data TEXT,
b03374f5 237 PRIMARY KEY(action_id)
cbcaf8c8 238);
69cc295f
VK
239
240
6c9e7d36
VK
241/*
242** Node groups
243*/
69cc295f 244
feea53fd 245CREATE TABLE node_groups
69cc295f
VK
246(
247 id integer not null,
3c468b80
VK
248 name varchar(64),
249 description varchar(255),
69cc295f
VK
250 PRIMARY KEY(id)
251);
252
253
6c9e7d36
VK
254/*
255** Event groups
256*/
69cc295f 257
feea53fd 258CREATE TABLE event_groups
69cc295f
VK
259(
260 id integer not null,
3c468b80
VK
261 name varchar(64),
262 description varchar(255),
69cc295f
VK
263 PRIMARY KEY(id)
264);
265
266
6c9e7d36
VK
267/*
268** Node group members
269*/
69cc295f 270
feea53fd 271CREATE TABLE node_group_members
69cc295f
VK
272(
273 group_id integer not null,
274 node_id integer not null,
3c468b80 275 PRIMARY KEY(group_id,node_id)
69cc295f
VK
276);
277
278
6c9e7d36
VK
279/*
280** Event group members
281*/
69cc295f 282
feea53fd 283CREATE TABLE event_group_members
69cc295f
VK
284(
285 group_id integer not null,
286 event_id integer not null,
3c468b80 287 PRIMARY KEY(group_id,event_id)
69cc295f
VK
288);
289
290
6c9e7d36
VK
291/*
292** Event processing policy
293*/
69cc295f 294
feea53fd 295CREATE TABLE event_policy
69cc295f 296(
59a21a78 297 rule_id integer not null, // Rule number
b6a77d6d 298 flags integer not null,
69cc295f 299 comments varchar(255),
59a21a78
VK
300 alarm_message varchar(255),
301 alarm_severity integer,
302 alarm_key varchar(255), // Alarm key (used for auto acknowlegment)
303 alarm_ack_key varchar(255), // Acknowlege all alarms with given key
304 alarm_ack_flag integer, // 1 if alarm will be acknowleged at creation time
305 PRIMARY KEY(rule_id)
69cc295f
VK
306);
307
feea53fd 308CREATE TABLE policy_source_list
69cc295f
VK
309(
310 rule_id integer not null,
69cc295f 311 object_id integer not null,
3c468b80 312 PRIMARY KEY(rule_id,object_id)
69cc295f
VK
313);
314
feea53fd 315CREATE TABLE policy_event_list
69cc295f
VK
316(
317 rule_id integer not null,
69cc295f 318 event_id integer not null,
b6a77d6d
VK
319 PRIMARY KEY(rule_id,event_id)
320);
321
feea53fd 322CREATE TABLE policy_action_list
b6a77d6d
VK
323(
324 rule_id integer not null,
325 action_id integer not null,
326 PRIMARY KEY(rule_id,action_id)
69cc295f 327);
54f0de5b
VK
328
329
330/*
331** Deleted objects
332*/
333
feea53fd 334CREATE TABLE deleted_objects
54f0de5b
VK
335(
336 object_id integer not null,
337 object_class integer,
338 name varchar(64),
339 ip_addr integer,
340 ip_netmask integer,
341 PRIMARY KEY(object_id)
342);
59f88625
VK
343
344
345/*
346** Threshold checking rules
347*/
348
feea53fd 349CREATE TABLE thresholds
59f88625
VK
350(
351 threshold_id integer not null,
352 item_id integer not null,
59a21a78 353 sequence_number integer not null,
59f88625
VK
354 fire_value varchar(255),
355 rearm_value varchar(255),
2fa71464
VK
356 check_function integer,
357 check_operation integer,
358 parameter_1 integer,
359 parameter_2 integer,
59f88625
VK
360 event_code integer,
361 PRIMARY KEY(threshold_id)
362);
2fa71464
VK
363
364
365/*
366** Data collection templates
367*/
368
feea53fd 369CREATE TABLE dct
2fa71464
VK
370(
371 template_id integer not null,
372 name varchar(255),
373 PRIMARY KEY(template_id)
374);
375
376
377/*
378** Items in data collection templates
379*/
380
feea53fd 381CREATE TABLE dct_items
2fa71464
VK
382(
383 template_id integer not null,
384 item_id integer not null,
385 name varchar(255),
386 description varchar(255),
387 source integer, // 0 for internal or 1 for native agent or 2 for SNMP
388 datatype integer,
389 polling_interval integer,
390 retention_time integer,
391 PRIMARY KEY(template_id,item_id)
392);
393
394
395/*
396** Mapping hosts to templates
397*/
398
feea53fd 399CREATE TABLE dct_host_map
2fa71464
VK
400(
401 template_id integer not null,
402 node_id integer not null,
403 PRIMARY KEY(template_id,node_id)
404);
59a21a78
VK
405
406
407/*
408** Alarms
409*/
410
411CREATE TABLE alarms
412(
413 alarm_id integer not null, // Unique alarm identifier
414 timestamp integer,
415 source integer,
416 message varchar(255),
417 severity integer,
418 alarm_key varchar(255), // Alarm key (used for auto acknowlegment)
419 is_ack integer, // TRUE if alarm is acknowleged
420 ack_by integer, // ID of user who acknowleges alarm
421 PRIMARY KEY(alarm_id)
422);
423
424
425/*
426** Alarm notes
427*/
428
429CREATE TABLE alarm_notes
430(
431 note_id integer not null,
432 alarm_id integer not null,
433 timestamp integer,
434 note_text DT_TEXT,
435 PRIMARY KEY(note_id)
436);