summaryrefslogtreecommitdiffstats
path: root/create/mysql/schema.sql
blob: 2faa7e3daf84ab8ab9871de75e03fea9240023dc (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
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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
-- 
-- ZABBIX
-- Copyright (C) 2000-2005 SIA Zabbix
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
--

--
-- Table structure for table 'nodes'
--

CREATE TABLE nodes (
  nodeid		int(4)		NOT NULL auto_increment,
  name			varchar(64)	DEFAULT '' NOT NULL,
  timezone		int(4)		DEFAULT '0' NOT NULL,
  ip			varchar(15)	DEFAULT '' NOT NULL,
  port			int(4)		DEFAULT '0' NOT NULL,
  slave_history		int(4)		DEFAULT '0' NOT NULL,
  slave_trends		int(4)		DEFAULT '0' NOT NULL,
  nodetype		int(4)		DEFAULT '0' NOT NULL,
  masterid		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (nodeid)
) type=InnoDB;

--
-- Table structure for table 'node_cksum'
--

CREATE TABLE node_cksum (
  cksumid		int(4)		NOT NULL auto_increment,
  nodeid		int(4)		DEFAULT '0' NOT NULL,
  tablename		varchar(64)	DEFAULT '' NOT NULL,
  fieldname		varchar(64)	DEFAULT '' NOT NULL,
  recordid		int(4)		DEFAULT '0' NOT NULL,
  cksumtype		int(4)		DEFAULT '0' NOT NULL,
  cksum			char(32)	DEFAULT '' NOT NULL,
  PRIMARY KEY (cksumid),
  KEY (nodeid,tablename,fieldname,recordid,cksumtype)
) type=InnoDB;

--
-- Table structure for table 'node_configlog'
--

CREATE TABLE node_configlog (
  conflogid		int(4)		NOT NULL auto_increment,
  nodeid		int(4)		DEFAULT '0' NOT NULL,
  tablename		varchar(64)	DEFAULT '' NOT NULL,
  recordid		int(4)		DEFAULT '0' NOT NULL,
  operation		int(4)		DEFAULT '0' NOT NULL,
  sync_master		int(4)		DEFAULT '0' NOT NULL,
  sync_slave		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (nodeid,conflogid),
  KEY (conflogid),
  KEY (nodeid,tablename)
) type=InnoDB;

--
-- Table structure for table 'services'
--

CREATE TABLE services (
  serviceid		int(4)		NOT NULL auto_increment,
  name			varchar(128)	DEFAULT '' NOT NULL,
  status		int(1)		DEFAULT '0' NOT NULL,
  algorithm		int(1)		DEFAULT '0' NOT NULL,
  triggerid		int(4),
  showsla		int(1)		DEFAULT '0' NOT NULL,
  goodsla		double(5,2)	DEFAULT '99.9' NOT NULL,
  sortorder		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (serviceid)
) type=InnoDB;

--
-- Table structure for table 'services_links'
--

CREATE TABLE services_links (
  linkid		int(4)		NOT NULL auto_increment,
  serviceupid		int(4)		DEFAULT '0' NOT NULL,
  servicedownid		int(4)		DEFAULT '0' NOT NULL,
  soft			int(1)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (linkid),
--  KEY (serviceupid),
  KEY (servicedownid),
  UNIQUE (serviceupid,servicedownid)
) type=InnoDB;

--
-- 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,
  drawtype		int(4)		DEFAULT '0' NOT NULL,
  sortorder		int(4)		DEFAULT '0' NOT NULL,
  color			varchar(32)	DEFAULT 'Dark Green' NOT NULL,
  yaxisside		int(1)		DEFAULT '1' NOT NULL,
  calc_fnc		int(1)		DEFAULT '2' NOT NULL,
  type			int(1)		DEFAULT '0' NOT NULL,
  periods_cnt		int(4)		DEFAULT '5' NOT NULL,
  PRIMARY KEY (gitemid)
) type=InnoDB;

--
-- 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,
  yaxistype		int(1)		DEFAULT '0' NOT NULL,
  yaxismin		double(16,4)	DEFAULT '0' NOT NULL,
  yaxismax		double(16,4)	DEFAULT '0' NOT NULL,
  templateid		int(4)		DEFAULT '0' NOT NULL,
  show_work_period	int(1)		DEFAULT '1' NOT NULL,
  show_triggers		int(1)		DEFAULT '1' NOT NULL,
  graphtype		int(2)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (graphid),
  KEY (name)
) type=InnoDB;

--
-- Table structure for table 'sysmaps_links'
--

CREATE TABLE sysmaps_links (
  linkid		int(4)		NOT NULL auto_increment,
  sysmapid		int(4)		DEFAULT '0' NOT NULL,
  selementid1		int(4)		DEFAULT '0' NOT NULL,
  selementid2		int(4)		DEFAULT '0' NOT NULL,
 -- may be NULL 
  triggerid		int(4),
  drawtype_off		int(4)		DEFAULT '0' NOT NULL,
  color_off		varchar(32)	DEFAULT 'Black' NOT NULL,
  drawtype_on		int(4)		DEFAULT '0' NOT NULL,
  color_on		varchar(32)	DEFAULT 'Red' NOT NULL,
  PRIMARY KEY (linkid)
) type=InnoDB;

--
-- Table structure for table 'sysmaps_elements'
--

CREATE TABLE sysmaps_elements (
  selementid		int(4)		NOT NULL auto_increment,
  sysmapid		int(4)		DEFAULT '0' NOT NULL,
  elementid		int(4)		DEFAULT '0' NOT NULL,
  elementtype		int(4)		DEFAULT '0' NOT NULL,
  icon			varchar(32)	DEFAULT 'Server' NOT NULL,
  icon_on		varchar(32)	DEFAULT 'Server' NOT NULL,
  label			varchar(128)	DEFAULT '' NOT NULL,
  label_location	int(1)		DEFAULT NULL,
  x			int(4)		DEFAULT '0' NOT NULL,
  y			int(4)		DEFAULT '0' NOT NULL,
  url			varchar(255)	DEFAULT '' NOT NULL,
  PRIMARY KEY (selementid)
) type=InnoDB;

--
-- 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,
  background		varchar(64)	DEFAULT '' NOT NULL,
  label_type		int(4)		DEFAULT '0' NOT NULL,
  label_location	int(1)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (sysmapid),
  UNIQUE (name)
) type=InnoDB;

--
-- Table structure for table 'config'
--

CREATE TABLE config (
  configid		int(4)		NOT NULL auto_increment,
--  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,
  alert_history		int(4)		DEFAULT '0' NOT NULL,
  alarm_history		int(4)		DEFAULT '0' NOT NULL,
  refresh_unsupported	int(4)		DEFAULT '0' NOT NULL,
  work_period		varchar(100)	DEFAULT '1-5,00:00-24:00' NOT NULL,
  PRIMARY KEY (configid)
) type=InnoDB;

--
-- 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)
  KEY (name)
) type=InnoDB;

--
-- Table structure for table 'hosts_groups'
--

CREATE TABLE hosts_groups (
  hostgroupid		int(4)		NOT NULL auto_increment,
  hostid		int(4)		DEFAULT '0' NOT NULL,
  groupid		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (hostgroupid),
--  UNIQUE (hostid,groupid)
  KEY (hostid,groupid)
) type=InnoDB;

--
-- Table structure for table 'alerts'
--

CREATE TABLE alerts (
  alertid		int(4)		NOT NULL auto_increment,
  actionid		int(4)		DEFAULT '0' NOT NULL,
  triggerid		int(4)		DEFAULT '0' NOT NULL,
  userid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
--  type		varchar(10)	DEFAULT '' NOT NULL,
  mediatypeid		int(4)		DEFAULT '0' NOT NULL,
  sendto		varchar(100)	DEFAULT '' NOT NULL,
  subject		varchar(255)	DEFAULT '' NOT NULL,
  message		blob		DEFAULT '' NOT NULL,
  status		int(4)		DEFAULT '0' NOT NULL,
  retries		int(4)		DEFAULT '0' NOT NULL,
  error			varchar(128)	DEFAULT '' NOT NULL,
  repeats		int(4)		DEFAULT '0' NOT NULL,
  maxrepeats		int(4)		DEFAULT '0' NOT NULL,
  nextcheck		int(4)		DEFAULT '0' NOT NULL,
  delay			int(4)		DEFAULT '0' NOT NULL,

  PRIMARY KEY (alertid),
  INDEX (actionid),
  KEY clock (clock),
  KEY triggerid (triggerid),
  KEY status_retries (status, retries),
  KEY mediatypeid (mediatypeid),
  KEY userid (userid)
) type=InnoDB;

--
-- Table structure for table 'actions'
--

CREATE TABLE actions (
  actionid		int(4)		NOT NULL auto_increment,
  userid		int(4)		DEFAULT '0' NOT NULL,
--delay			int(4)		DEFAULT '0' NOT NULL,
  subject		varchar(255)	DEFAULT '' NOT NULL,
  message		blob		DEFAULT '' NOT NULL,
--nextcheck		int(4)		DEFAULT '0' NOT NULL,
  recipient		int(1)		DEFAULT '0' NOT NULL,
  maxrepeats		int(4)		DEFAULT '0' NOT NULL,
  repeatdelay		int(4)		DEFAULT '600' NOT NULL,
  source		int(1)		DEFAULT '0' NOT NULL,
  actiontype		int(1)		DEFAULT '0' NOT NULL,
  status		int(1)		DEFAULT '0' NOT NULL,
  scripts		blob		DEFAULT '' NOT NULL,
  PRIMARY KEY (actionid)
) type=InnoDB;

--
-- Table structure for table 'conditions'
--

CREATE TABLE conditions (
  conditionid		int(4)		NOT NULL auto_increment,
  actionid		int(4)		DEFAULT '0' NOT NULL,
  conditiontype		int(4)		DEFAULT '0' NOT NULL,
  operator		int(1)		DEFAULT '0' NOT NULL,
  value			varchar(255)	DEFAULT '' NOT NULL,
  PRIMARY KEY (conditionid),
  KEY (actionid)
) type=InnoDB;

--
-- 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,
  value			int(4)		DEFAULT '0' NOT NULL,
  acknowledged		int(1)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (alarmid),
  KEY (triggerid,clock),
  KEY (clock)
) type=InnoDB;

--
-- 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		varchar(255),
  function		varchar(12)	DEFAULT '' NOT NULL,
  parameter		varchar(255)	DEFAULT '0' NOT NULL,
  PRIMARY KEY (functionid),
  KEY triggerid (triggerid),
  KEY itemidfunctionparameter (itemid,function,parameter)
) type=InnoDB;

--
-- 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)
  KEY itemidclock (itemid, clock)
) type=InnoDB;

--
-- Table structure for table 'history_uint'
--

CREATE TABLE history_uint (
  itemid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  value			bigint unsigned	DEFAULT '0' NOT NULL,
--  PRIMARY KEY (itemid,clock)
  KEY itemidclock (itemid, clock)
) type=InnoDB;

--
-- Table structure for table 'history_str'
--

CREATE TABLE history_str (
  itemid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  value			varchar(255)	DEFAULT '' NOT NULL,
--  PRIMARY KEY (itemid,clock)
  KEY itemidclock (itemid, clock)
) type=InnoDB;

--
-- Table structure for table 'hosts'
--

CREATE TABLE hosts (
	hostid		int(4)		NOT NULL auto_increment,
	host		varchar(64)	DEFAULT '' NOT NULL,
	useip		int(1)		DEFAULT '1' NOT NULL,
	ip		varchar(15)	DEFAULT '127.0.0.1' NOT NULL,
	port		int(4)		DEFAULT '0' NOT NULL,
	status		int(4)		DEFAULT '0' NOT NULL,
-- If status=UNREACHABLE, host will not be checked until this time
	disable_until	int(4)		DEFAULT '0' NOT NULL,
	error		varchar(128)	DEFAULT '' NOT NULL,
	available	int(4)		DEFAULT '0' NOT NULL,
	errors_from	int(4)		DEFAULT '0' NOT NULL,
	templateid	int(4)		DEFAULT '0' NOT NULL,
	PRIMARY KEY	(hostid),
--	UNIQUE		(host),
	KEY		(host),
	KEY		(status)
) type=InnoDB;

--
-- 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,
	snmp_port	int(4) DEFAULT '161' 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 '90' NOT NULL,
	trends		int(4) DEFAULT '365' NOT NULL,
-- lastdelete is not longer required
--	lastdelete	int(4) DEFAULT '0' NOT NULL,
	nextcheck	int(4) DEFAULT '0' NOT NULL,
	lastvalue	varchar(255) DEFAULT NULL,
	lastclock	int(4) DEFAULT NULL,
	prevvalue	varchar(255) DEFAULT NULL,
	status		int(4) DEFAULT '0' NOT NULL,
	value_type	int(4) DEFAULT '0' NOT NULL,
	trapper_hosts	varchar(255) DEFAULT '' NOT NULL,
	units		varchar(10)	DEFAULT '' NOT NULL,
	multiplier	int(4)	DEFAULT '0' NOT NULL,
	delta		int(1)  DEFAULT '0' NOT NULL,
	prevorgvalue	double(16,4)  DEFAULT NULL,
	snmpv3_securityname	varchar(64) DEFAULT '' NOT NULL,
	snmpv3_securitylevel	int(1) DEFAULT '0' NOT NULL,
	snmpv3_authpassphrase	varchar(64) DEFAULT '' NOT NULL,
	snmpv3_privpassphrase	varchar(64) DEFAULT '' NOT NULL,

	formula		varchar(255) DEFAULT '0' NOT NULL,
	error		varchar(128) DEFAULT '' NOT NULL,

	lastlogsize	int(4) DEFAULT '0' NOT NULL,
	logtimefmt	varchar(64) DEFAULT '' NOT NULL,
	templateid	int(4) DEFAULT '0' NOT NULL,
	valuemapid	int(4) DEFAULT '0' NOT NULL,

	PRIMARY KEY	(itemid),
	UNIQUE		shortname (hostid,key_),
--	KEY		(hostid),
	KEY		(nextcheck),
	KEY		(status)
) type=InnoDB;

--
-- 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,
	mediatypeid	int(4) DEFAULT '0' NOT NULL,
	sendto		varchar(100) DEFAULT '' NOT NULL,
	active		int(4) DEFAULT '0' NOT NULL,
	severity	int(4) DEFAULT '63' NOT NULL,
	period		varchar(100) DEFAULT '1-7,00:00-23:59' NOT NULL,
	PRIMARY KEY	(mediaid),
	KEY		(userid),
	KEY		(mediatypeid)
) type=InnoDB;

--
-- Table structure for table 'media'
--

CREATE TABLE media_type (
	mediatypeid	int(4) NOT NULL auto_increment,
	type		int(4)		DEFAULT '0' NOT NULL,
	description	varchar(100)	DEFAULT '' NOT NULL,
	smtp_server	varchar(255)	DEFAULT '' NOT NULL,
	smtp_helo	varchar(255)	DEFAULT '' NOT NULL,
	smtp_email	varchar(255)	DEFAULT '' NOT NULL,
	exec_path	varchar(255)	DEFAULT '' NOT NULL,
	gsm_modem	varchar(255)	DEFAULT '' NOT NULL,
	PRIMARY KEY	(mediatypeid)
) type=InnoDB;

--
-- 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,
	url		varchar(255) DEFAULT '' NOT NULL,
	status		int(4) DEFAULT '0' NOT NULL,
	value		int(4) DEFAULT '0' NOT NULL,
	priority	int(2) DEFAULT '0' NOT NULL,
	lastchange	int(4) DEFAULT '0' NOT NULL,
	dep_level	int(2) DEFAULT '0' NOT NULL,
	comments	blob,
	error		varchar(128) DEFAULT '' NOT NULL,
	templateid	int(4) DEFAULT '0' NOT NULL,
	PRIMARY KEY	(triggerid),
	KEY		(status),
	KEY		(value)
) type=InnoDB;

--
-- Table structure for table 'trigger_depends'
--

CREATE TABLE trigger_depends (
	triggerdepid	int(4) NOT NULL auto_increment,
	triggerid_down	int(4) DEFAULT '0' NOT NULL,
	triggerid_up	int(4) DEFAULT '0' NOT NULL,
	PRIMARY KEY	(triggerdepid),
	UNIQUE KEY	(triggerid_down, triggerid_up),
--	KEY		(triggerid_down),
	KEY		(triggerid_up)
) type=InnoDB;

--
-- Table structure for table 'users'
--

CREATE TABLE users (
  userid		int(4)		NOT NULL auto_increment,
  alias			varchar(100)	DEFAULT '' NOT NULL,
  name			varchar(100)	DEFAULT '' NOT NULL,
  surname		varchar(100)	DEFAULT '' NOT NULL,
  passwd		char(32)	DEFAULT '' NOT NULL,
  url			varchar(255)	DEFAULT '' NOT NULL,
  autologout		int(4)		DEFAULT '900' NOT NULL,
  lang			varchar(5)	DEFAULT 'en_gb' NOT NULL,
  refresh		int(4)		DEFAULT '30' NOT NULL,
  PRIMARY KEY (userid),
--  UNIQUE (alias)
  KEY (alias)
) type=InnoDB;

--
-- Table structure for table 'auditlog'
--

CREATE TABLE auditlog (
  auditid		int(4)		NOT NULL auto_increment,
  userid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  action		int(4)		DEFAULT '0' NOT NULL,
  resourcetype		int(4)		DEFAULT '0' NOT NULL,
  details		varchar(128)	DEFAULT '0' NOT NULL,
  PRIMARY KEY (auditid),
  KEY (userid,clock),
  KEY (clock)
) type=InnoDB;

--
-- Table structure for table 'sessions'
--

CREATE TABLE sessions (
  sessionid		varchar(32)	NOT NULL DEFAULT '',
  userid		int(4)		NOT NULL DEFAULT '0',
  lastaccess		int(4)		NOT NULL DEFAULT '0',
  PRIMARY KEY (sessionid)
) type=InnoDB;

--
-- Table structure for table 'rights'
--

CREATE TABLE rights (
  rightid		int(4)		NOT NULL auto_increment,
  userid		int(4)		DEFAULT '0' NOT NULL,
  name			char(255)	DEFAULT '' NOT NULL,
  permission		char(1)		DEFAULT '' NOT NULL,
  id			int(4),
  PRIMARY KEY (rightid),
  KEY (userid)
) type=InnoDB;

--
-- Table structure for table 'problems'
--

-- CREATE TABLE problems (
--   problemid		int(4)		NOT NULL auto_increment,
--   userid		int(4)		DEFAULT '0' NOT NULL,
--   triggerid		int(4),
--   lastupdate		int(4)		DEFAULT '0' NOT NULL,
--   clock			int(4)		DEFAULT '0' NOT NULL,
--   status		int(1)		DEFAULT '0' NOT NULL,
--   description		varchar(255)	DEFAULT '' NOT NULL,
--   categoryid		int(4),
  -- priority		int(1)		DEFAULT '0' NOT NULL,
--   PRIMARY KEY (problemid),
--   KEY (status),
--   KEY (categoryid),
--   KEY (priority)
-- ) type=InnoDB;

--
-- Table structure for table 'categories'
--

-- CREATE TABLE categories (
--   categoryid		int(4)		NOT NULL auto_increment,
--   descripion		varchar(64)	DEFAULT '' NOT NULL,
--   PRIMARY KEY (categoryid)
-- ) type=InnoDB;

--
-- Table structure for table 'problems_categories'
--

-- CREATE TABLE problems_comments (
--   commentid		int(4)		NOT NULL auto_increment,
--   problemid		int(4)		DEFAULT '0' NOT NULL,
--   clock			int(4),
--   status_before		int(1)		DEFAULT '0' NOT NULL,
--   status_after		int(1)		DEFAULT '0' NOT NULL,
--   comment		blob,
--   PRIMARY KEY (commentid),
--   KEY (problemid,clock)
-- ) type=InnoDB;

--
-- Table structure for table 'service_alarms'
--

CREATE TABLE service_alarms (
  servicealarmid	int(4)		NOT NULL auto_increment,
  serviceid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  value			int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (servicealarmid),
  KEY (serviceid,clock),
  KEY (clock)
) type=InnoDB;

--
-- Table structure for table 'profiles'
--

CREATE TABLE profiles (
  profileid		int(4)		NOT NULL auto_increment,
  userid		int(4)		DEFAULT '0' NOT NULL,
  idx			varchar(64)	DEFAULT '' NOT NULL,
  value			varchar(255)	DEFAULT '' NOT NULL,
  valuetype		int(4)		DEFAULT 0 NOT NULL,
  PRIMARY KEY (profileid),
--  KEY (userid),
  UNIQUE (userid,idx)
) type=InnoDB;

--
-- Table structure for table 'screens'
--

CREATE TABLE screens (
  screenid		int(4)		NOT NULL auto_increment,
  name			varchar(255)	DEFAULT 'Screen' NOT NULL,
  hsize			int(4)		DEFAULT '1' NOT NULL,
  vsize			int(4)		DEFAULT '1' NOT NULL,
  PRIMARY KEY  (screenid)
) TYPE=InnoDB;

--
-- Table structure for table 'screens_items'
--

CREATE TABLE screens_items (
	screenitemid	int(4)		NOT NULL auto_increment,
	screenid	int(4)		DEFAULT '0' NOT NULL,
	resourcetype	int(4)		DEFAULT '0' NOT NULL,
	resourceid	int(4)		DEFAULT '0' NOT NULL,
	width		int(4)		DEFAULT '320' NOT NULL,
	height		int(4)		DEFAULT '200' NOT NULL,
	x		int(4)		DEFAULT '0' NOT NULL,
	y		int(4)		DEFAULT '0' NOT NULL,
	colspan		int(4)		DEFAULT '0' NOT NULL,
	rowspan		int(4)		DEFAULT '0' NOT NULL,
	elements	int(4)		DEFAULT '25' NOT NULL,
	valign		int(2)		DEFAULT '0' NOT NULL,
	halign		int(2)		DEFAULT '0' NOT NULL,
	style		int(4)		DEFAULT '0' NOT NULL,
	url		varchar(255)	DEFAULT '' NOT NULL,
	PRIMARY KEY  (screenitemid)
) TYPE=InnoDB;

--
-- Table structure for table 'stats'
--

--CREATE TABLE stats (
--  itemid		int(4)		DEFAULT '0' NOT NULL,
--  year			int(4)		DEFAULT '0' NOT NULL,
--  month			int(4)		DEFAULT '0' NOT NULL,
--  day			int(4)		DEFAULT '0' NOT NULL,
--  hour			int(4)		DEFAULT '0' NOT NULL,
--  value_max		double(16,4)	DEFAULT '0.0000' NOT NULL,
--  value_min		double(16,4)	DEFAULT '0.0000' NOT NULL,
--  value_avg		double(16,4)	DEFAULT '0.0000' NOT NULL,
--  PRIMARY KEY (itemid,year,month,day,hour)
--) type=InnoDB;

--
-- Table structure for table 'usrgrp'
--

CREATE TABLE usrgrp (
  usrgrpid		int(4)		NOT NULL auto_increment,
  name			varchar(64)	DEFAULT '' NOT NULL,
  PRIMARY KEY (usrgrpid),
--  UNIQUE (name)
  KEY (name)
) type=InnoDB;

--
-- Table structure for table 'users_groups'
--

CREATE TABLE users_groups (
  id			int(4) NOT NULL auto_increment,
  usrgrpid		int(4)		DEFAULT '0' NOT NULL,
  userid		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (id),
--  UNIQUE (usrgrpid,userid)
  KEY (usrgrpid,userid)
) type=InnoDB;

--
-- Table structure for table 'trends'
--

CREATE TABLE trends (
  itemid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  num			int(2)		DEFAULT '0' NOT NULL,
  value_min		double(16,4)	DEFAULT '0.0000' NOT NULL,
  value_avg		double(16,4)	DEFAULT '0.0000' NOT NULL,
  value_max		double(16,4)	DEFAULT '0.0000' NOT NULL,
  PRIMARY KEY (itemid,clock)
) type=InnoDB;

--
-- Table structure for table 'images'
--

CREATE TABLE images (
  imageid		int(4)		NOT NULL auto_increment,
  imagetype		int(4)		DEFAULT '0' NOT NULL,
  name			varchar(64)	DEFAULT '0' NOT NULL,
  image			longblob	DEFAULT '' NOT NULL,
  PRIMARY KEY (imageid),
  UNIQUE (imagetype, name)
) type=InnoDB;

--
-- Table structure for table 'hosts_templates'
--

CREATE TABLE hosts_templates (
  hosttemplateid	int(4)		NOT NULL auto_increment,
  hostid		int(4)		DEFAULT '0' NOT NULL,
  templateid		int(4)		DEFAULT '0' NOT NULL,
  items			int(1)		DEFAULT '0' NOT NULL,
  triggers		int(1)		DEFAULT '0' NOT NULL,
  graphs		int(1)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (hosttemplateid),
  UNIQUE (hostid, templateid)
) type=InnoDB;

--
-- Table structure for table 'history_log'
--

CREATE TABLE history_log (
  id			int(4)		NOT NULL auto_increment,
  itemid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  timestamp		int(4)		DEFAULT '0' NOT NULL,
  source		varchar(64)	DEFAULT '' NOT NULL,
  severity		int(4)		DEFAULT '0' NOT NULL,
  value			text		DEFAULT '' NOT NULL,
  PRIMARY KEY (id),
  KEY itemidclock (itemid, clock)
) type=InnoDB;

--
-- Table structure for table 'history_text'
--

CREATE TABLE history_text (
  id			int(4)		NOT NULL auto_increment,
  itemid		int(4)		DEFAULT '0' NOT NULL,
  clock			int(4)		DEFAULT '0' NOT NULL,
  value			text		DEFAULT '' NOT NULL,
  PRIMARY KEY (id),
  KEY itemidclock (itemid, clock)
) type=InnoDB;

--
-- Table structure for table 'hosts_profiles'
--

CREATE TABLE hosts_profiles (
  hostid		int(4)		DEFAULT '0' NOT NULL,
  devicetype		varchar(64)	DEFAULT '' NOT NULL,
  name			varchar(64)	DEFAULT '' NOT NULL,
  os			varchar(64)	DEFAULT '' NOT NULL,
  serialno		varchar(64)	DEFAULT '' NOT NULL,
  tag			varchar(64)	DEFAULT '' NOT NULL,
  macaddress		varchar(64)	DEFAULT '' NOT NULL,
  hardware		blob		DEFAULT '' NOT NULL,
  software		blob		DEFAULT '' NOT NULL,
  contact		blob		DEFAULT '' NOT NULL,
  location		blob		DEFAULT '' NOT NULL,
  notes			blob		DEFAULT '' NOT NULL,
  PRIMARY KEY (hostid)
) type=InnoDB;

--
-- Table structure for table 'autoreg'
--

CREATE TABLE autoreg (
  id			int(4)		NOT NULL auto_increment,
  priority		int(4)		DEFAULT '0' NOT NULL,
  pattern		varchar(255)	DEFAULT '' NOT NULL,
  hostid		int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (id)
) type=InnoDB;

--
-- Table structure for table 'valuemaps'
--

CREATE TABLE valuemaps (
  valuemapid		int(4)		NOT NULL auto_increment,
  name			varchar(64)	DEFAULT '' NOT NULL,
  PRIMARY KEY (valuemapid),
  UNIQUE (name)
) type=InnoDB;

--
-- Table structure for table 'mapping'
--

CREATE TABLE mappings (
  mappingid		int(4)		NOT NULL auto_increment,
  valuemapid		int(4)		DEFAULT '0' NOT NULL,
  value			varchar(64)	DEFAULT '' NOT NULL,
  newvalue		varchar(64)	DEFAULT '' NOT NULL,
  PRIMARY KEY (mappingid),
  KEY valuemapid (valuemapid)
) type=InnoDB;

--
-- Table structure for table 'housekeeper'
--

CREATE TABLE housekeeper (
  housekeeperid		int(4)		NOT NULL auto_increment,
  tablename		varchar(64)	DEFAULT '' NOT NULL,
  field			varchar(64)	DEFAULT '' NOT NULL,
  value			int(4)		DEFAULT '0' NOT NULL,
  PRIMARY KEY (housekeeperid)
) type=InnoDB;

--
-- Table structure for table 'acknowledges'
--

CREATE TABLE acknowledges (
	acknowledgeid		int(4)		NOT NULL auto_increment,
	userid			int(4)		DEFAULT '0' NOT NULL,
	alarmid			int(4)		DEFAULT '0' NOT NULL,
	clock			int(4)		DEFAULT '0' NOT NULL,
	message			varchar(255)	DEFAULT '' NOT NULL,
	PRIMARY KEY (acknowledgeid),
	KEY userid (userid),
	KEY alarmid (alarmid),
	KEY clock (clock)
) type=InnoDB;

--
-- Table structure for table 'applications'
--

CREATE TABLE applications (
	applicationid           int(4)          NOT NULL auto_increment,
	hostid                  int(4)          DEFAULT '0' NOT NULL,
	name                    varchar(255)    DEFAULT '' NOT NULL,
	templateid		int(4)		DEFAULT '0' NOT NULL,
	PRIMARY KEY 	(applicationid),
	KEY 		templateid (templateid),
	UNIQUE          appname (hostid,name)
) type=InnoDB;

--
-- Table structure for table 'items_applications'
--

CREATE TABLE items_applications (
	itemappid		int(4)		NOT NULL auto_increment,
	applicationid           int(4)          DEFAULT '0' NOT NULL,
	itemid                  int(4)          DEFAULT '0' NOT NULL,
	PRIMARY KEY (itemappid),
	UNIQUE (applicationid,itemid)
) type=InnoDB;

--
-- Table structure for table 'help_items'
--

CREATE TABLE help_items (
	itemtype		int(4)          DEFAULT '0' NOT NULL,
	key_			varchar(64)	DEFAULT '' NOT NULL,
	description		varchar(255)	DEFAULT '' NOT NULL,
	PRIMARY KEY (itemtype, key_)
) type=InnoDB;