~ubuntu-dev/ubuntu/lucid/zabbix/lucid-201002110857

« back to all changes in this revision

Viewing changes to create/schema/sqlite.sql

  • Committer: Bazaar Package Importer
  • Author(s): Michael Ablassmeier
  • Date: 2007-07-02 09:06:51 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070702090651-8l6fl3fjw9rh6l2u
Tags: 1:1.4.1-2
Add patch from SVN in order to fix Incorrect processing of character '%'
in user parameters and remote commands.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
CREATE TABLE slideshows (
 
2
        slideshowid             bigint          DEFAULT '0'     NOT NULL,
 
3
        name            varchar(255)            DEFAULT ''      NOT NULL,
 
4
        delay           integer         DEFAULT '0'     NOT NULL,
 
5
        PRIMARY KEY (slideshowid)
 
6
);
 
7
CREATE TABLE slides (
 
8
        slideid         bigint          DEFAULT '0'     NOT NULL,
 
9
        slideshowid             bigint          DEFAULT '0'     NOT NULL,
 
10
        screenid                bigint          DEFAULT '0'     NOT NULL,
 
11
        step            integer         DEFAULT '0'     NOT NULL,
 
12
        delay           integer         DEFAULT '0'     NOT NULL,
 
13
        PRIMARY KEY (slideid)
 
14
);
 
15
CREATE INDEX slides_slides_1 on slides (slideshowid);
 
16
 
 
17
CREATE TABLE drules (
 
18
        druleid         bigint          DEFAULT '0'     NOT NULL,
 
19
        name            varchar(255)            DEFAULT ''      NOT NULL,
 
20
        iprange         varchar(255)            DEFAULT ''      NOT NULL,
 
21
        delay           integer         DEFAULT '0'     NOT NULL,
 
22
        nextcheck               integer         DEFAULT '0'     NOT NULL,
 
23
        status          integer         DEFAULT '0'     NOT NULL,
 
24
        PRIMARY KEY (druleid)
 
25
);
 
26
CREATE TABLE dchecks (
 
27
        dcheckid                bigint          DEFAULT '0'     NOT NULL,
 
28
        druleid         bigint          DEFAULT '0'     NOT NULL,
 
29
        type            integer         DEFAULT '0'     NOT NULL,
 
30
        key_            varchar(255)            DEFAULT '0'     NOT NULL,
 
31
        snmp_community          varchar(255)            DEFAULT '0'     NOT NULL,
 
32
        ports           varchar(255)            DEFAULT '0'     NOT NULL,
 
33
        PRIMARY KEY (dcheckid)
 
34
);
 
35
CREATE TABLE dhosts (
 
36
        dhostid         bigint          DEFAULT '0'     NOT NULL,
 
37
        druleid         bigint          DEFAULT '0'     NOT NULL,
 
38
        ip              varchar(15)             DEFAULT ''      NOT NULL,
 
39
        status          integer         DEFAULT '0'     NOT NULL,
 
40
        lastup          integer         DEFAULT '0'     NOT NULL,
 
41
        lastdown                integer         DEFAULT '0'     NOT NULL,
 
42
        PRIMARY KEY (dhostid)
 
43
);
 
44
CREATE TABLE dservices (
 
45
        dserviceid              bigint          DEFAULT '0'     NOT NULL,
 
46
        dhostid         bigint          DEFAULT '0'     NOT NULL,
 
47
        type            integer         DEFAULT '0'     NOT NULL,
 
48
        key_            varchar(255)            DEFAULT '0'     NOT NULL,
 
49
        value           varchar(255)            DEFAULT '0'     NOT NULL,
 
50
        port            integer         DEFAULT '0'     NOT NULL,
 
51
        status          integer         DEFAULT '0'     NOT NULL,
 
52
        lastup          integer         DEFAULT '0'     NOT NULL,
 
53
        lastdown                integer         DEFAULT '0'     NOT NULL,
 
54
        PRIMARY KEY (dserviceid)
 
55
);
 
56
CREATE TABLE ids (
 
57
        nodeid          integer         DEFAULT '0'     NOT NULL,
 
58
        table_name              varchar(64)             DEFAULT ''      NOT NULL,
 
59
        field_name              varchar(64)             DEFAULT ''      NOT NULL,
 
60
        nextid          bigint          DEFAULT '0'     NOT NULL,
 
61
        PRIMARY KEY (nodeid,table_name,field_name)
 
62
);
 
63
CREATE TABLE httptest (
 
64
        httptestid              bigint          DEFAULT '0'     NOT NULL,
 
65
        name            varchar(64)             DEFAULT ''      NOT NULL,
 
66
        applicationid           bigint          DEFAULT '0'     NOT NULL,
 
67
        lastcheck               integer         DEFAULT '0'     NOT NULL,
 
68
        nextcheck               integer         DEFAULT '0'     NOT NULL,
 
69
        curstate                integer         DEFAULT '0'     NOT NULL,
 
70
        curstep         integer         DEFAULT '0'     NOT NULL,
 
71
        lastfailedstep          integer         DEFAULT '0'     NOT NULL,
 
72
        delay           integer         DEFAULT '60'    NOT NULL,
 
73
        status          integer         DEFAULT '0'     NOT NULL,
 
74
        macros          blob            DEFAULT ''      NOT NULL,
 
75
        agent           varchar(255)            DEFAULT ''      NOT NULL,
 
76
        time            double(16,4)            DEFAULT '0'     NOT NULL,
 
77
        error           varchar(255)            DEFAULT ''      NOT NULL,
 
78
        PRIMARY KEY (httptestid)
 
79
);
 
80
CREATE TABLE httpstep (
 
81
        httpstepid              bigint          DEFAULT '0'     NOT NULL,
 
82
        httptestid              bigint          DEFAULT '0'     NOT NULL,
 
83
        name            varchar(64)             DEFAULT ''      NOT NULL,
 
84
        no              integer         DEFAULT '0'     NOT NULL,
 
85
        url             varchar(128)            DEFAULT ''      NOT NULL,
 
86
        timeout         integer         DEFAULT '30'    NOT NULL,
 
87
        posts           blob            DEFAULT ''      NOT NULL,
 
88
        required                varchar(255)            DEFAULT ''      NOT NULL,
 
89
        status_codes            varchar(255)            DEFAULT ''      NOT NULL,
 
90
        PRIMARY KEY (httpstepid)
 
91
);
 
92
CREATE INDEX httpstep_httpstep_1 on httpstep (httptestid);
 
93
 
 
94
CREATE TABLE httpstepitem (
 
95
        httpstepitemid          bigint          DEFAULT '0'     NOT NULL,
 
96
        httpstepid              bigint          DEFAULT '0'     NOT NULL,
 
97
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
98
        type            integer         DEFAULT '0'     NOT NULL,
 
99
        PRIMARY KEY (httpstepitemid)
 
100
);
 
101
CREATE UNIQUE INDEX httpstepitem_httpstepitem_1 on httpstepitem (httpstepid,itemid);
 
102
 
 
103
CREATE TABLE httptestitem (
 
104
        httptestitemid          bigint          DEFAULT '0'     NOT NULL,
 
105
        httptestid              bigint          DEFAULT '0'     NOT NULL,
 
106
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
107
        type            integer         DEFAULT '0'     NOT NULL,
 
108
        PRIMARY KEY (httptestitemid)
 
109
);
 
110
CREATE UNIQUE INDEX httptestitem_httptestitem_1 on httptestitem (httptestid,itemid);
 
111
 
 
112
CREATE TABLE nodes (
 
113
        nodeid          integer         DEFAULT '0'     NOT NULL,
 
114
        name            varchar(64)             DEFAULT '0'     NOT NULL,
 
115
        timezone                integer         DEFAULT '0'     NOT NULL,
 
116
        ip              varchar(15)             DEFAULT ''      NOT NULL,
 
117
        port            integer         DEFAULT '10051' NOT NULL,
 
118
        slave_history           integer         DEFAULT '30'    NOT NULL,
 
119
        slave_trends            integer         DEFAULT '365'   NOT NULL,
 
120
        event_lastid            bigint          DEFAULT '0'     NOT NULL,
 
121
        history_lastid          bigint          DEFAULT '0'     NOT NULL,
 
122
        history_str_lastid              bigint          DEFAULT '0'     NOT NULL,
 
123
        history_uint_lastid             bigint          DEFAULT '0'     NOT NULL,
 
124
        nodetype                integer         DEFAULT '0'     NOT NULL,
 
125
        masterid                integer         DEFAULT '0'     NOT NULL,
 
126
        PRIMARY KEY (nodeid)
 
127
);
 
128
CREATE TABLE node_cksum (
 
129
        cksumid         bigint          DEFAULT '0'     NOT NULL,
 
130
        nodeid          bigint          DEFAULT '0'     NOT NULL,
 
131
        tablename               varchar(64)             DEFAULT ''      NOT NULL,
 
132
        fieldname               varchar(64)             DEFAULT ''      NOT NULL,
 
133
        recordid                bigint          DEFAULT '0'     NOT NULL,
 
134
        cksumtype               integer         DEFAULT '0'     NOT NULL,
 
135
        cksum           char(32)                DEFAULT ''      NOT NULL,
 
136
        PRIMARY KEY (cksumid)
 
137
);
 
138
CREATE INDEX node_cksum_cksum_1 on node_cksum (nodeid,tablename,fieldname,recordid,cksumtype);
 
139
 
 
140
CREATE TABLE node_configlog (
 
141
        conflogid               bigint          DEFAULT '0'     NOT NULL,
 
142
        nodeid          bigint          DEFAULT '0'     NOT NULL,
 
143
        tablename               varchar(64)             DEFAULT ''      NOT NULL,
 
144
        recordid                bigint          DEFAULT '0'     NOT NULL,
 
145
        operation               integer         DEFAULT '0'     NOT NULL,
 
146
        sync_master             integer         DEFAULT '0'     NOT NULL,
 
147
        sync_slave              integer         DEFAULT '0'     NOT NULL,
 
148
        PRIMARY KEY (nodeid,conflogid)
 
149
);
 
150
CREATE INDEX node_configlog_configlog_1 on node_configlog (conflogid);
 
151
CREATE INDEX node_configlog_configlog_2 on node_configlog (nodeid,tablename);
 
152
 
 
153
CREATE TABLE history_str_sync (
 
154
        id              serial                  ,
 
155
        nodeid          bigint          DEFAULT '0'     NOT NULL,
 
156
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
157
        clock           integer         DEFAULT '0'     NOT NULL,
 
158
        value           varchar(255)            DEFAULT ''      NOT NULL,
 
159
        PRIMARY KEY (id)
 
160
);
 
161
CREATE INDEX history_str_sync_1 on history_str_sync (nodeid,id);
 
162
 
 
163
CREATE TABLE history_sync (
 
164
        id              serial                  ,
 
165
        nodeid          bigint          DEFAULT '0'     NOT NULL,
 
166
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
167
        clock           integer         DEFAULT '0'     NOT NULL,
 
168
        value           double(16,4)            DEFAULT '0.0000'        NOT NULL,
 
169
        PRIMARY KEY (id)
 
170
);
 
171
CREATE INDEX history_sync_1 on history_sync (nodeid,id);
 
172
 
 
173
CREATE TABLE history_uint_sync (
 
174
        id              serial                  ,
 
175
        nodeid          bigint          DEFAULT '0'     NOT NULL,
 
176
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
177
        clock           integer         DEFAULT '0'     NOT NULL,
 
178
        value           bigint          DEFAULT '0'     NOT NULL,
 
179
        PRIMARY KEY (id)
 
180
);
 
181
CREATE INDEX history_uint_sync_1 on history_uint_sync (nodeid,id);
 
182
 
 
183
CREATE TABLE services_times (
 
184
        timeid          bigint          DEFAULT '0'     NOT NULL,
 
185
        serviceid               bigint          DEFAULT '0'     NOT NULL,
 
186
        type            integer         DEFAULT '0'     NOT NULL,
 
187
        ts_from         integer         DEFAULT '0'     NOT NULL,
 
188
        ts_to           integer         DEFAULT '0'     NOT NULL,
 
189
        note            varchar(255)            DEFAULT ''      NOT NULL,
 
190
        PRIMARY KEY (timeid)
 
191
);
 
192
CREATE INDEX services_times_times_1 on services_times (serviceid,type,ts_from,ts_to);
 
193
 
 
194
CREATE TABLE alerts (
 
195
        alertid         bigint          DEFAULT '0'     NOT NULL,
 
196
        actionid                bigint          DEFAULT '0'     NOT NULL,
 
197
        triggerid               bigint          DEFAULT '0'     NOT NULL,
 
198
        userid          bigint          DEFAULT '0'     NOT NULL,
 
199
        clock           integer         DEFAULT '0'     NOT NULL,
 
200
        mediatypeid             bigint          DEFAULT '0'     NOT NULL,
 
201
        sendto          varchar(100)            DEFAULT ''      NOT NULL,
 
202
        subject         varchar(255)            DEFAULT ''      NOT NULL,
 
203
        message         blob            DEFAULT ''      NOT NULL,
 
204
        status          integer         DEFAULT '0'     NOT NULL,
 
205
        retries         integer         DEFAULT '0'     NOT NULL,
 
206
        error           varchar(128)            DEFAULT ''      NOT NULL,
 
207
        nextcheck               integer         DEFAULT '0'     NOT NULL,
 
208
        PRIMARY KEY (alertid)
 
209
);
 
210
CREATE INDEX alerts_1 on alerts (actionid);
 
211
CREATE INDEX alerts_2 on alerts (clock);
 
212
CREATE INDEX alerts_3 on alerts (triggerid);
 
213
CREATE INDEX alerts_4 on alerts (status,retries);
 
214
CREATE INDEX alerts_5 on alerts (mediatypeid);
 
215
CREATE INDEX alerts_6 on alerts (userid);
 
216
 
 
217
CREATE TABLE events (
 
218
        eventid         bigint          DEFAULT '0'     NOT NULL,
 
219
        source          integer         DEFAULT '0'     NOT NULL,
 
220
        object          integer         DEFAULT '0'     NOT NULL,
 
221
        objectid                bigint          DEFAULT '0'     NOT NULL,
 
222
        clock           integer         DEFAULT '0'     NOT NULL,
 
223
        value           integer         DEFAULT '0'     NOT NULL,
 
224
        acknowledged            integer         DEFAULT '0'     NOT NULL,
 
225
        PRIMARY KEY (eventid)
 
226
);
 
227
CREATE INDEX events_1 on events (object,objectid,clock);
 
228
CREATE INDEX events_2 on events (clock);
 
229
 
 
230
CREATE TABLE history (
 
231
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
232
        clock           integer         DEFAULT '0'     NOT NULL,
 
233
        value           double(16,4)            DEFAULT '0.0000'        NOT NULL
 
234
);
 
235
CREATE INDEX history_1 on history (itemid,clock);
 
236
 
 
237
CREATE TABLE history_uint (
 
238
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
239
        clock           integer         DEFAULT '0'     NOT NULL,
 
240
        value           bigint          DEFAULT '0'     NOT NULL
 
241
);
 
242
CREATE INDEX history_uint_1 on history_uint (itemid,clock);
 
243
 
 
244
CREATE TABLE history_str (
 
245
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
246
        clock           integer         DEFAULT '0'     NOT NULL,
 
247
        value           varchar(255)            DEFAULT ''      NOT NULL
 
248
);
 
249
CREATE INDEX history_str_1 on history_str (itemid,clock);
 
250
 
 
251
CREATE TABLE history_log (
 
252
        id              bigint          DEFAULT '0'     NOT NULL,
 
253
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
254
        clock           integer         DEFAULT '0'     NOT NULL,
 
255
        timestamp               integer         DEFAULT '0'     NOT NULL,
 
256
        source          varchar(64)             DEFAULT ''      NOT NULL,
 
257
        severity                integer         DEFAULT '0'     NOT NULL,
 
258
        value           text            DEFAULT ''      NOT NULL,
 
259
        PRIMARY KEY (id)
 
260
);
 
261
CREATE INDEX history_log_1 on history_log (itemid,clock);
 
262
 
 
263
CREATE TABLE history_text (
 
264
        id              bigint          DEFAULT '0'     NOT NULL,
 
265
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
266
        clock           integer         DEFAULT '0'     NOT NULL,
 
267
        value           text            DEFAULT ''      NOT NULL,
 
268
        PRIMARY KEY (id)
 
269
);
 
270
CREATE INDEX history_text_1 on history_text (itemid,clock);
 
271
 
 
272
CREATE TABLE trends (
 
273
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
274
        clock           integer         DEFAULT '0'     NOT NULL,
 
275
        num             integer         DEFAULT '0'     NOT NULL,
 
276
        value_min               double(16,4)            DEFAULT '0.0000'        NOT NULL,
 
277
        value_avg               double(16,4)            DEFAULT '0.0000'        NOT NULL,
 
278
        value_max               double(16,4)            DEFAULT '0.0000'        NOT NULL,
 
279
        PRIMARY KEY (itemid,clock)
 
280
);
 
281
CREATE TABLE acknowledges (
 
282
        acknowledgeid           bigint          DEFAULT '0'     NOT NULL,
 
283
        userid          bigint          DEFAULT '0'     NOT NULL,
 
284
        eventid         bigint          DEFAULT '0'     NOT NULL,
 
285
        clock           integer         DEFAULT '0'     NOT NULL,
 
286
        message         varchar(255)            DEFAULT ''      NOT NULL,
 
287
        PRIMARY KEY (acknowledgeid)
 
288
);
 
289
CREATE INDEX acknowledges_1 on acknowledges (userid);
 
290
CREATE INDEX acknowledges_2 on acknowledges (eventid);
 
291
CREATE INDEX acknowledges_3 on acknowledges (clock);
 
292
 
 
293
CREATE TABLE actions (
 
294
        actionid                bigint          DEFAULT '0'     NOT NULL,
 
295
        name            varchar(255)            DEFAULT ''      NOT NULL,
 
296
        eventsource             integer         DEFAULT '0'     NOT NULL,
 
297
        evaltype                integer         DEFAULT '0'     NOT NULL,
 
298
        status          integer         DEFAULT '0'     NOT NULL,
 
299
        PRIMARY KEY (actionid)
 
300
);
 
301
CREATE TABLE operations (
 
302
        operationid             bigint          DEFAULT '0'     NOT NULL,
 
303
        actionid                bigint          DEFAULT '0'     NOT NULL,
 
304
        operationtype           integer         DEFAULT '0'     NOT NULL,
 
305
        object          integer         DEFAULT '0'     NOT NULL,
 
306
        objectid                bigint          DEFAULT '0'     NOT NULL,
 
307
        shortdata               varchar(255)            DEFAULT ''      NOT NULL,
 
308
        longdata                blob            DEFAULT ''      NOT NULL,
 
309
        PRIMARY KEY (operationid)
 
310
);
 
311
CREATE INDEX operations_1 on operations (actionid);
 
312
 
 
313
CREATE TABLE applications (
 
314
        applicationid           bigint          DEFAULT '0'     NOT NULL,
 
315
        hostid          bigint          DEFAULT '0'     NOT NULL,
 
316
        name            varchar(255)            DEFAULT ''      NOT NULL,
 
317
        templateid              bigint          DEFAULT '0'     NOT NULL,
 
318
        PRIMARY KEY (applicationid)
 
319
);
 
320
CREATE INDEX applications_1 on applications (templateid);
 
321
CREATE UNIQUE INDEX applications_2 on applications (hostid,name);
 
322
 
 
323
CREATE TABLE auditlog (
 
324
        auditid         bigint          DEFAULT '0'     NOT NULL,
 
325
        userid          bigint          DEFAULT '0'     NOT NULL,
 
326
        clock           integer         DEFAULT '0'     NOT NULL,
 
327
        action          integer         DEFAULT '0'     NOT NULL,
 
328
        resourcetype            integer         DEFAULT '0'     NOT NULL,
 
329
        details         varchar(128)            DEFAULT '0'     NOT NULL,
 
330
        PRIMARY KEY (auditid)
 
331
);
 
332
CREATE INDEX auditlog_1 on auditlog (userid,clock);
 
333
CREATE INDEX auditlog_2 on auditlog (clock);
 
334
 
 
335
CREATE TABLE conditions (
 
336
        conditionid             bigint          DEFAULT '0'     NOT NULL,
 
337
        actionid                bigint          DEFAULT '0'     NOT NULL,
 
338
        conditiontype           integer         DEFAULT '0'     NOT NULL,
 
339
        operator                integer         DEFAULT '0'     NOT NULL,
 
340
        value           varchar(255)            DEFAULT ''      NOT NULL,
 
341
        PRIMARY KEY (conditionid)
 
342
);
 
343
CREATE INDEX conditions_1 on conditions (actionid);
 
344
 
 
345
CREATE TABLE config (
 
346
        configid                bigint          DEFAULT '0'     NOT NULL,
 
347
        alert_history           integer         DEFAULT '0'     NOT NULL,
 
348
        event_history           integer         DEFAULT '0'     NOT NULL,
 
349
        refresh_unsupported             integer         DEFAULT '0'     NOT NULL,
 
350
        work_period             varchar(100)            DEFAULT '1-5,00:00-24:00'       NOT NULL,
 
351
        alert_usrgrpid          bigint          DEFAULT '0'     NOT NULL,
 
352
        PRIMARY KEY (configid)
 
353
);
 
354
CREATE TABLE functions (
 
355
        functionid              bigint          DEFAULT '0'     NOT NULL,
 
356
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
357
        triggerid               bigint          DEFAULT '0'     NOT NULL,
 
358
        lastvalue               varchar(255)                    ,
 
359
        function                varchar(12)             DEFAULT ''      NOT NULL,
 
360
        parameter               varchar(255)            DEFAULT '0'     NOT NULL,
 
361
        PRIMARY KEY (functionid)
 
362
);
 
363
CREATE INDEX functions_1 on functions (triggerid);
 
364
CREATE INDEX functions_2 on functions (itemid,function,parameter);
 
365
 
 
366
CREATE TABLE graphs (
 
367
        graphid         bigint          DEFAULT '0'     NOT NULL,
 
368
        name            varchar(128)            DEFAULT ''      NOT NULL,
 
369
        width           integer         DEFAULT '0'     NOT NULL,
 
370
        height          integer         DEFAULT '0'     NOT NULL,
 
371
        yaxistype               integer         DEFAULT '0'     NOT NULL,
 
372
        yaxismin                double(16,4)            DEFAULT '0'     NOT NULL,
 
373
        yaxismax                double(16,4)            DEFAULT '0'     NOT NULL,
 
374
        templateid              bigint          DEFAULT '0'     NOT NULL,
 
375
        show_work_period                integer         DEFAULT '1'     NOT NULL,
 
376
        show_triggers           integer         DEFAULT '1'     NOT NULL,
 
377
        graphtype               integer         DEFAULT '0'     NOT NULL,
 
378
        PRIMARY KEY (graphid)
 
379
);
 
380
CREATE INDEX graphs_graphs_1 on graphs (name);
 
381
 
 
382
CREATE TABLE graphs_items (
 
383
        gitemid         bigint          DEFAULT '0'     NOT NULL,
 
384
        graphid         bigint          DEFAULT '0'     NOT NULL,
 
385
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
386
        drawtype                integer         DEFAULT '0'     NOT NULL,
 
387
        sortorder               integer         DEFAULT '0'     NOT NULL,
 
388
        color           varchar(32)             DEFAULT 'Dark Green'    NOT NULL,
 
389
        yaxisside               integer         DEFAULT '1'     NOT NULL,
 
390
        calc_fnc                integer         DEFAULT '2'     NOT NULL,
 
391
        type            integer         DEFAULT '0'     NOT NULL,
 
392
        periods_cnt             integer         DEFAULT '5'     NOT NULL,
 
393
        PRIMARY KEY (gitemid)
 
394
);
 
395
CREATE TABLE groups (
 
396
        groupid         bigint          DEFAULT '0'     NOT NULL,
 
397
        name            varchar(64)             DEFAULT ''      NOT NULL,
 
398
        PRIMARY KEY (groupid)
 
399
);
 
400
CREATE INDEX groups_1 on groups (name);
 
401
 
 
402
CREATE TABLE help_items (
 
403
        itemtype                integer         DEFAULT '0'     NOT NULL,
 
404
        key_            varchar(255)            DEFAULT ''      NOT NULL,
 
405
        description             varchar(255)            DEFAULT ''      NOT NULL,
 
406
        PRIMARY KEY (itemtype,key_)
 
407
);
 
408
CREATE TABLE hosts (
 
409
        hostid          bigint          DEFAULT '0'     NOT NULL,
 
410
        host            varchar(64)             DEFAULT ''      NOT NULL,
 
411
        dns             varchar(64)             DEFAULT ''      NOT NULL,
 
412
        useip           integer         DEFAULT '1'     NOT NULL,
 
413
        ip              varchar(15)             DEFAULT '127.0.0.1'     NOT NULL,
 
414
        port            integer         DEFAULT '10050' NOT NULL,
 
415
        status          integer         DEFAULT '0'     NOT NULL,
 
416
        disable_until           integer         DEFAULT '0'     NOT NULL,
 
417
        error           varchar(128)            DEFAULT ''      NOT NULL,
 
418
        available               integer         DEFAULT '0'     NOT NULL,
 
419
        errors_from             integer         DEFAULT '0'     NOT NULL,
 
420
        PRIMARY KEY (hostid)
 
421
);
 
422
CREATE INDEX hosts_1 on hosts (host);
 
423
CREATE INDEX hosts_2 on hosts (status);
 
424
 
 
425
CREATE TABLE hosts_groups (
 
426
        hostgroupid             bigint          DEFAULT '0'     NOT NULL,
 
427
        hostid          bigint          DEFAULT '0'     NOT NULL,
 
428
        groupid         bigint          DEFAULT '0'     NOT NULL,
 
429
        PRIMARY KEY (hostgroupid)
 
430
);
 
431
CREATE INDEX hosts_groups_groups_1 on hosts_groups (hostid,groupid);
 
432
 
 
433
CREATE TABLE hosts_profiles (
 
434
        hostid          bigint          DEFAULT '0'     NOT NULL,
 
435
        devicetype              varchar(64)             DEFAULT ''      NOT NULL,
 
436
        name            varchar(64)             DEFAULT ''      NOT NULL,
 
437
        os              varchar(64)             DEFAULT ''      NOT NULL,
 
438
        serialno                varchar(64)             DEFAULT ''      NOT NULL,
 
439
        tag             varchar(64)             DEFAULT ''      NOT NULL,
 
440
        macaddress              varchar(64)             DEFAULT ''      NOT NULL,
 
441
        hardware                blob            DEFAULT ''      NOT NULL,
 
442
        software                blob            DEFAULT ''      NOT NULL,
 
443
        contact         blob            DEFAULT ''      NOT NULL,
 
444
        location                blob            DEFAULT ''      NOT NULL,
 
445
        notes           blob            DEFAULT ''      NOT NULL,
 
446
        PRIMARY KEY (hostid)
 
447
);
 
448
CREATE TABLE hosts_templates (
 
449
        hosttemplateid          bigint          DEFAULT '0'     NOT NULL,
 
450
        hostid          bigint          DEFAULT '0'     NOT NULL,
 
451
        templateid              bigint          DEFAULT '0'     NOT NULL,
 
452
        PRIMARY KEY (hosttemplateid)
 
453
);
 
454
CREATE UNIQUE INDEX hosts_templates_1 on hosts_templates (hostid,templateid);
 
455
 
 
456
CREATE TABLE housekeeper (
 
457
        housekeeperid           bigint          DEFAULT '0'     NOT NULL,
 
458
        tablename               varchar(64)             DEFAULT ''      NOT NULL,
 
459
        field           varchar(64)             DEFAULT ''      NOT NULL,
 
460
        value           bigint          DEFAULT '0'     NOT NULL,
 
461
        PRIMARY KEY (housekeeperid)
 
462
);
 
463
CREATE TABLE images (
 
464
        imageid         bigint          DEFAULT '0'     NOT NULL,
 
465
        imagetype               integer         DEFAULT '0'     NOT NULL,
 
466
        name            varchar(64)             DEFAULT '0'     NOT NULL,
 
467
        image           longblob                DEFAULT ''      NOT NULL,
 
468
        PRIMARY KEY (imageid)
 
469
);
 
470
CREATE INDEX images_1 on images (imagetype,name);
 
471
 
 
472
CREATE TABLE items (
 
473
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
474
        type            integer         DEFAULT '0'     NOT NULL,
 
475
        snmp_community          varchar(64)             DEFAULT ''      NOT NULL,
 
476
        snmp_oid                varchar(255)            DEFAULT ''      NOT NULL,
 
477
        snmp_port               integer         DEFAULT '161'   NOT NULL,
 
478
        hostid          bigint          DEFAULT '0'     NOT NULL,
 
479
        description             varchar(255)            DEFAULT ''      NOT NULL,
 
480
        key_            varchar(255)            DEFAULT ''      NOT NULL,
 
481
        delay           integer         DEFAULT '0'     NOT NULL,
 
482
        history         integer         DEFAULT '90'    NOT NULL,
 
483
        trends          integer         DEFAULT '365'   NOT NULL,
 
484
        nextcheck               integer         DEFAULT '0'     NOT NULL,
 
485
        lastvalue               varchar(255)                    NULL,
 
486
        lastclock               integer                 NULL,
 
487
        prevvalue               varchar(255)                    NULL,
 
488
        status          integer         DEFAULT '0'     NOT NULL,
 
489
        value_type              integer         DEFAULT '0'     NOT NULL,
 
490
        trapper_hosts           varchar(255)            DEFAULT ''      NOT NULL,
 
491
        units           varchar(10)             DEFAULT ''      NOT NULL,
 
492
        multiplier              integer         DEFAULT '0'     NOT NULL,
 
493
        delta           integer         DEFAULT '0'     NOT NULL,
 
494
        prevorgvalue            varchar(255)                    NULL,
 
495
        snmpv3_securityname             varchar(64)             DEFAULT ''      NOT NULL,
 
496
        snmpv3_securitylevel            integer         DEFAULT '0'     NOT NULL,
 
497
        snmpv3_authpassphrase           varchar(64)             DEFAULT ''      NOT NULL,
 
498
        snmpv3_privpassphrase           varchar(64)             DEFAULT ''      NOT NULL,
 
499
        formula         varchar(255)            DEFAULT '1'     NOT NULL,
 
500
        error           varchar(128)            DEFAULT ''      NOT NULL,
 
501
        lastlogsize             integer         DEFAULT '0'     NOT NULL,
 
502
        logtimefmt              varchar(64)             DEFAULT ''      NOT NULL,
 
503
        templateid              bigint          DEFAULT '0'     NOT NULL,
 
504
        valuemapid              bigint          DEFAULT '0'     NOT NULL,
 
505
        delay_flex              varchar(255)            DEFAULT ''      NOT NULL,
 
506
        params          text            DEFAULT ''      NOT NULL,
 
507
        PRIMARY KEY (itemid)
 
508
);
 
509
CREATE UNIQUE INDEX items_1 on items (hostid,key_);
 
510
CREATE INDEX items_2 on items (nextcheck);
 
511
CREATE INDEX items_3 on items (status);
 
512
 
 
513
CREATE TABLE items_applications (
 
514
        itemappid               bigint          DEFAULT '0'     NOT NULL,
 
515
        applicationid           bigint          DEFAULT '0'     NOT NULL,
 
516
        itemid          bigint          DEFAULT '0'     NOT NULL,
 
517
        PRIMARY KEY (itemappid)
 
518
);
 
519
CREATE INDEX items_applications_1 on items_applications (applicationid,itemid);
 
520
 
 
521
CREATE TABLE mappings (
 
522
        mappingid               bigint          DEFAULT '0'     NOT NULL,
 
523
        valuemapid              bigint          DEFAULT '0'     NOT NULL,
 
524
        value           varchar(64)             DEFAULT ''      NOT NULL,
 
525
        newvalue                varchar(64)             DEFAULT ''      NOT NULL,
 
526
        PRIMARY KEY (mappingid)
 
527
);
 
528
CREATE INDEX mappings_1 on mappings (valuemapid);
 
529
 
 
530
CREATE TABLE media (
 
531
        mediaid         bigint          DEFAULT '0'     NOT NULL,
 
532
        userid          bigint          DEFAULT '0'     NOT NULL,
 
533
        mediatypeid             bigint          DEFAULT '0'     NOT NULL,
 
534
        sendto          varchar(100)            DEFAULT ''      NOT NULL,
 
535
        active          integer         DEFAULT '0'     NOT NULL,
 
536
        severity                integer         DEFAULT '63'    NOT NULL,
 
537
        period          varchar(100)            DEFAULT '1-7,00:00-23:59'       NOT NULL,
 
538
        PRIMARY KEY (mediaid)
 
539
);
 
540
CREATE INDEX media_1 on media (userid);
 
541
CREATE INDEX media_2 on media (mediatypeid);
 
542
 
 
543
CREATE TABLE media_type (
 
544
        mediatypeid             bigint          DEFAULT '0'     NOT NULL,
 
545
        type            integer         DEFAULT '0'     NOT NULL,
 
546
        description             varchar(100)            DEFAULT ''      NOT NULL,
 
547
        smtp_server             varchar(255)            DEFAULT ''      NOT NULL,
 
548
        smtp_helo               varchar(255)            DEFAULT ''      NOT NULL,
 
549
        smtp_email              varchar(255)            DEFAULT ''      NOT NULL,
 
550
        exec_path               varchar(255)            DEFAULT ''      NOT NULL,
 
551
        gsm_modem               varchar(255)            DEFAULT ''      NOT NULL,
 
552
        username                varchar(255)            DEFAULT ''      NOT NULL,
 
553
        passwd          varchar(255)            DEFAULT ''      NOT NULL,
 
554
        PRIMARY KEY (mediatypeid)
 
555
);
 
556
CREATE TABLE profiles (
 
557
        profileid               bigint          DEFAULT '0'     NOT NULL,
 
558
        userid          bigint          DEFAULT '0'     NOT NULL,
 
559
        idx             varchar(64)             DEFAULT ''      NOT NULL,
 
560
        value           varchar(255)            DEFAULT ''      NOT NULL,
 
561
        valuetype               integer         DEFAULT 0       NOT NULL,
 
562
        PRIMARY KEY (profileid)
 
563
);
 
564
CREATE UNIQUE INDEX profiles_1 on profiles (userid,idx);
 
565
 
 
566
CREATE TABLE rights (
 
567
        rightid         bigint          DEFAULT '0'     NOT NULL,
 
568
        groupid         bigint          DEFAULT '0'     NOT NULL,
 
569
        type            integer         DEFAULT '0'     NOT NULL,
 
570
        permission              integer         DEFAULT '0'     NOT NULL,
 
571
        id              bigint                  ,
 
572
        PRIMARY KEY (rightid)
 
573
);
 
574
CREATE INDEX rights_1 on rights (groupid);
 
575
 
 
576
CREATE TABLE screens (
 
577
        screenid                bigint          DEFAULT '0'     NOT NULL,
 
578
        name            varchar(255)            DEFAULT 'Screen'        NOT NULL,
 
579
        hsize           integer         DEFAULT '1'     NOT NULL,
 
580
        vsize           integer         DEFAULT '1'     NOT NULL,
 
581
        PRIMARY KEY (screenid)
 
582
);
 
583
CREATE TABLE screens_items (
 
584
        screenitemid            bigint          DEFAULT '0'     NOT NULL,
 
585
        screenid                bigint          DEFAULT '0'     NOT NULL,
 
586
        resourcetype            integer         DEFAULT '0'     NOT NULL,
 
587
        resourceid              bigint          DEFAULT '0'     NOT NULL,
 
588
        width           integer         DEFAULT '320'   NOT NULL,
 
589
        height          integer         DEFAULT '200'   NOT NULL,
 
590
        x               integer         DEFAULT '0'     NOT NULL,
 
591
        y               integer         DEFAULT '0'     NOT NULL,
 
592
        colspan         integer         DEFAULT '0'     NOT NULL,
 
593
        rowspan         integer         DEFAULT '0'     NOT NULL,
 
594
        elements                integer         DEFAULT '25'    NOT NULL,
 
595
        valign          integer         DEFAULT '0'     NOT NULL,
 
596
        halign          integer         DEFAULT '0'     NOT NULL,
 
597
        style           integer         DEFAULT '0'     NOT NULL,
 
598
        url             varchar(255)            DEFAULT ''      NOT NULL,
 
599
        PRIMARY KEY (screenitemid)
 
600
);
 
601
CREATE TABLE services (
 
602
        serviceid               bigint          DEFAULT '0'     NOT NULL,
 
603
        name            varchar(128)            DEFAULT ''      NOT NULL,
 
604
        status          integer         DEFAULT '0'     NOT NULL,
 
605
        algorithm               integer         DEFAULT '0'     NOT NULL,
 
606
        triggerid               bigint                  ,
 
607
        showsla         integer         DEFAULT '0'     NOT NULL,
 
608
        goodsla         double(5,2)             DEFAULT '99.9'  NOT NULL,
 
609
        sortorder               integer         DEFAULT '0'     NOT NULL,
 
610
        PRIMARY KEY (serviceid)
 
611
);
 
612
CREATE TABLE service_alarms (
 
613
        servicealarmid          bigint          DEFAULT '0'     NOT NULL,
 
614
        serviceid               bigint          DEFAULT '0'     NOT NULL,
 
615
        clock           integer         DEFAULT '0'     NOT NULL,
 
616
        value           integer         DEFAULT '0'     NOT NULL,
 
617
        PRIMARY KEY (servicealarmid)
 
618
);
 
619
CREATE INDEX service_alarms_1 on service_alarms (serviceid,clock);
 
620
CREATE INDEX service_alarms_2 on service_alarms (clock);
 
621
 
 
622
CREATE TABLE services_links (
 
623
        linkid          bigint          DEFAULT '0'     NOT NULL,
 
624
        serviceupid             bigint          DEFAULT '0'     NOT NULL,
 
625
        servicedownid           bigint          DEFAULT '0'     NOT NULL,
 
626
        soft            integer         DEFAULT '0'     NOT NULL,
 
627
        PRIMARY KEY (linkid)
 
628
);
 
629
CREATE INDEX services_links_links_1 on services_links (servicedownid);
 
630
CREATE UNIQUE INDEX services_links_links_2 on services_links (serviceupid,servicedownid);
 
631
 
 
632
CREATE TABLE sessions (
 
633
        sessionid               varchar(32)             DEFAULT ''      NOT NULL,
 
634
        userid          bigint          DEFAULT '0'     NOT NULL,
 
635
        lastaccess              integer         DEFAULT '0'     NOT NULL,
 
636
        PRIMARY KEY (sessionid)
 
637
);
 
638
CREATE TABLE sysmaps_links (
 
639
        linkid          bigint          DEFAULT '0'     NOT NULL,
 
640
        sysmapid                bigint          DEFAULT '0'     NOT NULL,
 
641
        selementid1             bigint          DEFAULT '0'     NOT NULL,
 
642
        selementid2             bigint          DEFAULT '0'     NOT NULL,
 
643
        triggerid               bigint                  ,
 
644
        drawtype_off            integer         DEFAULT '0'     NOT NULL,
 
645
        color_off               varchar(32)             DEFAULT 'Black' NOT NULL,
 
646
        drawtype_on             integer         DEFAULT '0'     NOT NULL,
 
647
        color_on                varchar(32)             DEFAULT 'Red'   NOT NULL,
 
648
        PRIMARY KEY (linkid)
 
649
);
 
650
CREATE TABLE sysmaps_elements (
 
651
        selementid              bigint          DEFAULT '0'     NOT NULL,
 
652
        sysmapid                bigint          DEFAULT '0'     NOT NULL,
 
653
        elementid               bigint          DEFAULT '0'     NOT NULL,
 
654
        elementtype             integer         DEFAULT '0'     NOT NULL,
 
655
        iconid_off              bigint          DEFAULT '0'     NOT NULL,
 
656
        iconid_on               bigint          DEFAULT '0'     NOT NULL,
 
657
        iconid_unknown          bigint          DEFAULT '0'     NOT NULL,
 
658
        label           varchar(128)            DEFAULT ''      NOT NULL,
 
659
        label_location          integer                 NULL,
 
660
        x               integer         DEFAULT '0'     NOT NULL,
 
661
        y               integer         DEFAULT '0'     NOT NULL,
 
662
        url             varchar(255)            DEFAULT ''      NOT NULL,
 
663
        PRIMARY KEY (selementid)
 
664
);
 
665
CREATE TABLE sysmaps (
 
666
        sysmapid                bigint          DEFAULT '0'     NOT NULL,
 
667
        name            varchar(128)            DEFAULT ''      NOT NULL,
 
668
        width           integer         DEFAULT '0'     NOT NULL,
 
669
        height          integer         DEFAULT '0'     NOT NULL,
 
670
        backgroundid            bigint          DEFAULT '0'     NOT NULL,
 
671
        label_type              integer         DEFAULT '0'     NOT NULL,
 
672
        label_location          integer         DEFAULT '0'     NOT NULL,
 
673
        PRIMARY KEY (sysmapid)
 
674
);
 
675
CREATE INDEX sysmaps_1 on sysmaps (name);
 
676
 
 
677
CREATE TABLE triggers (
 
678
        triggerid               bigint          DEFAULT '0'     NOT NULL,
 
679
        expression              varchar(255)            DEFAULT ''      NOT NULL,
 
680
        description             varchar(255)            DEFAULT ''      NOT NULL,
 
681
        url             varchar(255)            DEFAULT ''      NOT NULL,
 
682
        status          integer         DEFAULT '0'     NOT NULL,
 
683
        value           integer         DEFAULT '0'     NOT NULL,
 
684
        priority                integer         DEFAULT '0'     NOT NULL,
 
685
        lastchange              integer         DEFAULT '0'     NOT NULL,
 
686
        dep_level               integer         DEFAULT '0'     NOT NULL,
 
687
        comments                blob                    ,
 
688
        error           varchar(128)            DEFAULT ''      NOT NULL,
 
689
        templateid              bigint          DEFAULT '0'     NOT NULL,
 
690
        PRIMARY KEY (triggerid)
 
691
);
 
692
CREATE INDEX triggers_1 on triggers (status);
 
693
CREATE INDEX triggers_2 on triggers (value);
 
694
 
 
695
CREATE TABLE trigger_depends (
 
696
        triggerdepid            bigint          DEFAULT '0'     NOT NULL,
 
697
        triggerid_down          bigint          DEFAULT '0'     NOT NULL,
 
698
        triggerid_up            bigint          DEFAULT '0'     NOT NULL,
 
699
        PRIMARY KEY (triggerdepid)
 
700
);
 
701
CREATE INDEX trigger_depends_1 on trigger_depends (triggerid_down,triggerid_up);
 
702
CREATE INDEX trigger_depends_2 on trigger_depends (triggerid_up);
 
703
 
 
704
CREATE TABLE users (
 
705
        userid          bigint          DEFAULT '0'     NOT NULL,
 
706
        alias           varchar(100)            DEFAULT ''      NOT NULL,
 
707
        name            varchar(100)            DEFAULT ''      NOT NULL,
 
708
        surname         varchar(100)            DEFAULT ''      NOT NULL,
 
709
        passwd          char(32)                DEFAULT ''      NOT NULL,
 
710
        url             varchar(255)            DEFAULT ''      NOT NULL,
 
711
        autologout              integer         DEFAULT '900'   NOT NULL,
 
712
        lang            varchar(5)              DEFAULT 'en_gb' NOT NULL,
 
713
        refresh         integer         DEFAULT '30'    NOT NULL,
 
714
        type            integer         DEFAULT '0'     NOT NULL,
 
715
        PRIMARY KEY (userid)
 
716
);
 
717
CREATE INDEX users_1 on users (alias);
 
718
 
 
719
CREATE TABLE usrgrp (
 
720
        usrgrpid                bigint          DEFAULT '0'     NOT NULL,
 
721
        name            varchar(64)             DEFAULT ''      NOT NULL,
 
722
        PRIMARY KEY (usrgrpid)
 
723
);
 
724
CREATE INDEX usrgrp_1 on usrgrp (name);
 
725
 
 
726
CREATE TABLE users_groups (
 
727
        id              bigint          DEFAULT '0'     NOT NULL,
 
728
        usrgrpid                bigint          DEFAULT '0'     NOT NULL,
 
729
        userid          bigint          DEFAULT '0'     NOT NULL,
 
730
        PRIMARY KEY (id)
 
731
);
 
732
CREATE INDEX users_groups_1 on users_groups (usrgrpid,userid);
 
733
 
 
734
CREATE TABLE valuemaps (
 
735
        valuemapid              bigint          DEFAULT '0'     NOT NULL,
 
736
        name            varchar(64)             DEFAULT ''      NOT NULL,
 
737
        PRIMARY KEY (valuemapid)
 
738
);
 
739
CREATE INDEX valuemaps_1 on valuemaps (name);
 
740