summaryrefslogtreecommitdiffstats
path: root/create/mysql/schema.sql
blob: 0f73f6b92698fed7ca0f2e5d7919ed52df6ee8d0 (plain)
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
#
# Table structure for table 'graphs_items'
#

CREATE TABLE graphs_items (
  gitemid		int(4)		NOT NULL auto_increment,
  graphid		int(4)		DEFAULT '0' NOT NULL,
  itemid		int(4)		DEFAULT '0' NOT NULL,
  color			varchar(32)	DEFAULT 'Dark Green' NOT NULL,
  PRIMARY KEY (gitemid)
);
# Foreign keys

#
# Table structure for table 'graphs'
#

CREATE TABLE graphs (
  graphid		int(4)		NOT NULL auto_increment,
  name			varchar(128)	DEFAULT '' NOT NULL,
  width			int(4)		DEFAULT '0' NOT NULL,
  height		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (graphid),
  UNIQUE (name)
);
# Foreign keys

#
# Table structure for table 'sysmaps_links'
#

CREATE TABLE sysmaps_links (
  linkid		int(4)		NOT NULL auto_increment,
  sysmapid		int(4)		DEFAULT '0' NOT NULL,
  shostid1		int(4)		DEFAULT '0' NOT NULL,
  shostid2		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (linkid)
);
# Foreign keys

#
# Table structure for table 'sysmaps_hosts'
#

CREATE TABLE sysmaps_hosts (
  shostid		int(4)		NOT NULL auto_increment,
  sysmapid		int(4)		DEFAULT '0' NOT NULL,
  hostid		int(4)		DEFAULT '0' NOT NULL,
  label			varchar(128)	DEFAULT '' NOT NULL,
  x			int(4)		DEFAULT '0' NOT NULL,
  y			int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (shostid)
);

# Foreign keys

#
# Table structure for table 'sysmaps'
#

CREATE TABLE sysmaps (
  sysmapid		int(4)		NOT NULL auto_increment,
  name			varchar(128)	DEFAULT '' NOT NULL,
  width			int(4)		DEFAULT '0' NOT NULL,
  height		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (sysmapid),
  UNIQUE (name)
);

#
# 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	int(1)		DEFAULT '0' NOT NULL
);

#
# Table structure for table 'groups'
#

CREATE TABLE groups (
  groupid		int(4)		NOT NULL auto_increment,
  name			varchar(64)	DEFAULT '' NOT NULL,
  PRIMARY KEY (groupid),
  UNIQUE (name)
);

#
# Table structure for table 'alerts'
#

CREATE TABLE alerts (
  alertid		int(4)		NOT NULL auto_increment,
  actionid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  type			varchar(10)	DEFAULT '' NOT NULL,
  sendto		varchar(100)	DEFAULT '' NOT NULL,
  subject		varchar(255)	DEFAULT '' NOT NULL,
  message		varchar(255)	DEFAULT '' NOT NULL,
  PRIMARY KEY (alertid),
  INDEX (actionid),
  KEY clock (clock)
);

#
# Table structure for table 'actions'
#

CREATE TABLE actions (
  actionid		int(4)		NOT NULL auto_increment,
  triggerid		int(4)		DEFAULT '0' NOT NULL,
  userid		int(4)		DEFAULT '0' NOT NULL,
  good			int(4)		DEFAULT '0' NOT NULL,
  delay			int(4)		DEFAULT '0' NOT NULL,
  subject		varchar(255)	DEFAULT '' NOT NULL,
  message		varchar(255)	DEFAULT '' NOT NULL,
  nextcheck		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (actionid),
  KEY (triggerid)
);

#
# Table structure for table 'alarms'
#

CREATE TABLE alarms (
  alarmid		int(4)		NOT NULL auto_increment,
  triggerid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  istrue		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (alarmid)
);

#
# Table structure for table 'functions'
#

CREATE TABLE functions (
  functionid int(4) NOT NULL auto_increment,
  itemid int(4) DEFAULT '0' NOT NULL,
  triggerid int(4) DEFAULT '0' NOT NULL,
  lastvalue double(16,4) DEFAULT '0.0000' NOT NULL,
  function varchar(10) DEFAULT '' NOT NULL,
  parameter int(4) DEFAULT '0' NOT NULL,
  PRIMARY KEY (functionid),
  KEY itemid (itemid),
  KEY triggerid (triggerid),
  UNIQUE itemidfunctionparameter (itemid,function,parameter)
);

#
# Table structure for table 'history'
#

CREATE TABLE history (
  itemid int(4) DEFAULT '0' NOT NULL,
  clock int(4) DEFAULT '0' NOT NULL,
  value double(16,4) DEFAULT '0.0000' NOT NULL,
  PRIMARY KEY (itemid,clock)
);

#
# Table structure for table 'hosts'
#

CREATE TABLE hosts (
  hostid int(4) NOT NULL auto_increment,
  host varchar(64) DEFAULT '' NOT NULL,
  port int(4) DEFAULT '0' NOT NULL,
  status int(4) DEFAULT '0' NOT NULL,
  PRIMARY KEY (hostid),
  KEY (status)
);

#
# Table structure for table 'items_template'
#

CREATE TABLE items_template (
  itemtemplateid int(4) NOT NULL,
  description varchar(255) DEFAULT '' NOT NULL,
  key_ varchar(64) DEFAULT '' NOT NULL,
  delay int(4) DEFAULT '0' NOT NULL,
  PRIMARY KEY (itemtemplateid),
  UNIQUE (key_)
);

#
# Table structure for table 'triggers_template'
#

CREATE TABLE triggers_template (
  triggertemplateid int(4) NOT NULL,
  itemtemplateid int(4) NOT NULL,
  description varchar(255) DEFAULT '' NOT NULL,
  expression varchar(255) DEFAULT '' NOT NULL,
  PRIMARY KEY (triggertemplateid),
  KEY (itemtemplateid)
);

#
# Table structure for table 'items'
#

CREATE TABLE items (
	itemid		int(4) NOT NULL auto_increment,
	type		int(4) DEFAULT '0' NOT NULL,
	snmp_community	varchar(64) DEFAULT '' NOT NULL,
	snmp_oid	varchar(255) DEFAULT '' NOT NULL,
	hostid		int(4) NOT NULL,
	description	varchar(255) DEFAULT '' NOT NULL,
	key_		varchar(64) DEFAULT '' NOT NULL,
	delay		int(4) DEFAULT '0' NOT NULL,
	history		int(4) DEFAULT '0' NOT NULL,
	lastdelete	int(4) DEFAULT '0' NOT NULL,
	nextcheck	int(4) DEFAULT '0' NOT NULL,
	lastvalue	double(16,4) DEFAULT NULL,
	lastclock	int(4) DEFAULT NULL,
	prevvalue	double(16,4) DEFAULT NULL,
	status		int(4) DEFAULT '0' NOT NULL,
	PRIMARY KEY (itemid),
	UNIQUE shortname (hostid,key_),
	KEY (hostid),
	KEY (nextcheck),
	KEY (status)
);

#
# Table structure for table 'media'
#

CREATE TABLE media (
  mediaid int(4) NOT NULL auto_increment,
  userid int(4) DEFAULT '0' NOT NULL,
  type varchar(10) DEFAULT '' NOT NULL,
  sendto varchar(100) DEFAULT '' NOT NULL,
  active int(4) DEFAULT '0' NOT NULL,
  PRIMARY KEY (mediaid),
  KEY (userid)
);

#
# Table structure for table 'triggers'
#

CREATE TABLE triggers (
  triggerid int(4) NOT NULL auto_increment,
  expression varchar(255) DEFAULT '' NOT NULL,
  description varchar(255) DEFAULT '' NOT NULL,
  istrue int(4) DEFAULT '0' NOT NULL,
  lastcheck int(4) DEFAULT '0' NOT NULL,
  priority int(2) DEFAULT '0' NOT NULL,
  lastchange int(4) DEFAULT '0' NOT NULL,
  comments blob,
  PRIMARY KEY (triggerid),
  KEY (istrue)
);

#
# Table structure for table 'users'
#

CREATE TABLE users (
  userid		int(4)		NOT NULL auto_increment,
  groupid		int(4)		NOT NULL DEFAULT '0',
  alias			varchar(100)	DEFAULT '' NOT NULL,
  name			varchar(100)	DEFAULT '' NOT NULL,
  surname		varchar(100)	DEFAULT '' NOT NULL,
  passwd		varchar(64)	DEFAULT '' NOT NULL,
  PRIMARY KEY (userid),
  UNIQUE (alias)
);