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