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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
\connect zabbix
--
-- Table structure for table 'hosts'
--
CREATE TABLE hosts (
hostid serial,
host varchar(64) DEFAULT '' NOT NULL,
useip int4 DEFAULT '0' NOT NULL,
ip varchar(15) DEFAULT '127.0.0.1' NOT NULL,
port int4 DEFAULT '0' NOT NULL,
status int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (hostid)
);
CREATE INDEX hosts_status on hosts (status);
--
-- Table structure for table 'items'
--
CREATE TABLE items (
itemid serial,
type int4 NOT NULL,
snmp_community varchar(64) DEFAULT '' NOT NULL,
snmp_oid varchar(255) DEFAULT '' NOT NULL,
hostid int4 NOT NULL,
description varchar(255) DEFAULT '' NOT NULL,
key_ varchar(64) DEFAULT '' NOT NULL,
delay int4 DEFAULT '0' NOT NULL,
history int4 DEFAULT '0' NOT NULL,
lastdelete int4 DEFAULT '0' NOT NULL,
nextcheck int4 DEFAULT '0' NOT NULL,
lastvalue float8 DEFAULT NULL,
lastclock int4 DEFAULT NULL,
prevvalue float8 DEFAULT NULL,
status int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (itemid),
FOREIGN KEY (hostid) REFERENCES hosts
);
CREATE UNIQUE INDEX items_hostid_key on items (hostid,key_);
CREATE INDEX items_hostid on items (hostid);
CREATE INDEX items_nextcheck on items (nextcheck);
CREATE INDEX items_status on items (status);
--
-- Table structure for table 'config'
--
CREATE TABLE config (
smtp_server varchar(255) DEFAULT '' NOT NULL,
smtp_helo varchar(255) DEFAULT '' NOT NULL,
smtp_email varchar(255) DEFAULT '' NOT NULL,
password_required int4 DEFAULT '0' NOT NULL
);
--
-- Table structure for table 'groups'
--
CREATE TABLE groups (
groupid serial,
name varchar(64) DEFAULT '' NOT NULL,
PRIMARY KEY (groupid)
);
--
-- Table structure for table 'triggers'
--
CREATE TABLE triggers (
triggerid serial,
expression varchar(255) DEFAULT '' NOT NULL,
description varchar(255) DEFAULT '' NOT NULL,
istrue int4 DEFAULT '0' NOT NULL,
lastcheck int4 DEFAULT '0' NOT NULL,
priority int2 DEFAULT '0' NOT NULL,
lastchange int4 DEFAULT '0' NOT NULL,
comments text,
PRIMARY KEY (triggerid)
);
CREATE INDEX triggers_istrue on triggers (istrue);
--
-- Table structure for table 'users'
--
CREATE TABLE users (
userid serial,
groupid int4 NOT NULL DEFAULT '0',
alias varchar(100) DEFAULT '' NOT NULL,
name varchar(100) DEFAULT '' NOT NULL,
surname varchar(100) DEFAULT '' NOT NULL,
passwd char(32) DEFAULT '' NOT NULL,
PRIMARY KEY (userid),
FOREIGN KEY (groupid) REFERENCES groups
);
CREATE UNIQUE INDEX users_alias on users (alias);
--
-- Table structure for table 'actions'
--
CREATE TABLE actions (
actionid serial,
triggerid int4 DEFAULT '0' NOT NULL,
userid int4 DEFAULT '0' NOT NULL,
good int4 DEFAULT '0' NOT NULL,
delay int4 DEFAULT '0' NOT NULL,
subject varchar(255) DEFAULT '' NOT NULL,
message text DEFAULT '' NOT NULL,
nextcheck int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (actionid),
FOREIGN KEY (triggerid) REFERENCES triggers,
FOREIGN KEY (userid) REFERENCES users
);
--
-- Table structure for table 'alerts'
--
CREATE TABLE alerts (
alertid serial,
actionid int4 DEFAULT '0' NOT NULL,
clock int4 DEFAULT '0' NOT NULL,
type varchar(10) DEFAULT '' NOT NULL,
sendto varchar(100) DEFAULT '' NOT NULL,
subject varchar(255) DEFAULT '' NOT NULL,
message text DEFAULT '' NOT NULL,
PRIMARY KEY (alertid),
FOREIGN KEY (actionid) REFERENCES actions
);
CREATE INDEX alerts_actionid on alerts (actionid);
CREATE INDEX alerts_clock on alerts (clock);
--
-- Table structure for table 'alarms'
--
CREATE TABLE alarms (
alarmid serial,
triggerid int4 DEFAULT '0' NOT NULL,
clock int4 DEFAULT '0' NOT NULL,
istrue int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (alarmid),
FOREIGN KEY (triggerid) REFERENCES triggers
);
CREATE INDEX alarms_triggerid_clock on alarms (triggerid, clock);
--
-- Table structure for table 'functions'
--
CREATE TABLE functions (
functionid serial,
itemid int4 DEFAULT '0' NOT NULL,
triggerid int4 DEFAULT '0' NOT NULL,
lastvalue float8 DEFAULT '0.0000' NOT NULL,
function varchar(10) DEFAULT '' NOT NULL,
parameter int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (functionid),
FOREIGN KEY (itemid) REFERENCES items,
FOREIGN KEY (triggerid) REFERENCES triggers
);
CREATE INDEX functions_itemid on functions (itemid);
CREATE INDEX funtions_triggerid on functions (triggerid);
CREATE UNIQUE INDEX functions_i_f_p on functions (itemid,function,parameter);
--
-- Table structure for table 'history'
--
CREATE TABLE history (
itemid int4 DEFAULT '0' NOT NULL,
clock int4 DEFAULT '0' NOT NULL,
value float8 DEFAULT '0.0000' NOT NULL,
PRIMARY KEY (itemid,clock),
FOREIGN KEY (itemid) REFERENCES items
);
--
-- Table structure for table 'items_template'
--
CREATE TABLE items_template (
itemtemplateid int4 NOT NULL,
description varchar(255) DEFAULT '' NOT NULL,
key_ varchar(64) DEFAULT '' NOT NULL,
delay int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (itemtemplateid)
);
CREATE UNIQUE INDEX items_template_p_k on items_template (key_);
--
-- Table structure for table 'triggers_template'
--
CREATE TABLE triggers_template (
triggertemplateid int4 NOT NULL,
itemtemplateid int4 NOT NULL,
description varchar(255) DEFAULT '' NOT NULL,
expression varchar(255) DEFAULT '' NOT NULL,
PRIMARY KEY (triggertemplateid),
FOREIGN KEY (itemtemplateid) REFERENCES items_template
);
--
-- Table structure for table 'media'
--
CREATE TABLE media (
mediaid serial,
userid int4 DEFAULT '0' NOT NULL,
type varchar(10) DEFAULT '' NOT NULL,
sendto varchar(100) DEFAULT '' NOT NULL,
active int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (mediaid),
FOREIGN KEY (userid) REFERENCES users
);
--
-- Table structure for table 'sysmaps'
--
CREATE TABLE sysmaps (
sysmapid serial,
name varchar(128) DEFAULT '' NOT NULL,
width int4 DEFAULT '0' NOT NULL,
height int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (sysmapid)
);
CREATE UNIQUE INDEX sysmaps_name on sysmaps (name);
--
-- Table structure for table 'sysmaps_hosts'
--
CREATE TABLE sysmaps_hosts (
shostid serial,
sysmapid int4 DEFAULT '0' NOT NULL,
hostid int4 DEFAULT '0' NOT NULL,
icon varchar(32) DEFAULT 'Server' NOT NULL,
label varchar(128) DEFAULT '' NOT NULL,
x int4 DEFAULT '0' NOT NULL,
y int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (shostid),
FOREIGN KEY (sysmapid) REFERENCES sysmaps,
FOREIGN KEY (hostid) REFERENCES hosts
);
--
-- Table structure for table 'sysmaps_links'
--
CREATE TABLE sysmaps_links (
linkid serial,
sysmapid int4 DEFAULT '0' NOT NULL,
shostid1 int4 DEFAULT '0' NOT NULL,
shostid2 int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (linkid),
FOREIGN KEY (sysmapid) REFERENCES sysmaps,
FOREIGN KEY (shostid1) REFERENCES sysmaps_hosts,
FOREIGN KEY (shostid2) REFERENCES sysmaps_hosts
);
--
-- Table structure for table 'graphs'
--
CREATE TABLE graphs (
graphid serial,
name varchar(128) DEFAULT '' NOT NULL,
width int4 DEFAULT '0' NOT NULL,
height int4 DEFAULT '0' NOT NULL,
PRIMARY KEY (graphid),
UNIQUE (name)
);
CREATE UNIQUE INDEX graphs_name on graphs (name);
--
-- Table structure for table 'graphs_items'
--
CREATE TABLE graphs_items (
gitemid serial,
graphid int4 DEFAULT '0' NOT NULL,
itemid int4 DEFAULT '0' NOT NULL,
color varchar(32) DEFAULT 'Dark Green' NOT NULL,
PRIMARY KEY (gitemid),
FOREIGN KEY (graphid) REFERENCES graphs,
FOREIGN KEY (itemid) REFERENCES items
);
VACUUM ANALYZE;
|