]> granicus.if.org Git - icinga2/blob - lib/db_ido_mysql/schema/mysql.sql
Alter DowntimeRemoval behaviour
[icinga2] / lib / db_ido_mysql / schema / mysql.sql
1 -- --------------------------------------------------------
2 -- mysql.sql
3 -- DB definition for IDO MySQL
4 --
5 -- Copyright (c) 2009-2017 Icinga Development Team (https://www.icinga.com/)
6 --
7 -- -- --------------------------------------------------------
8
9 /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
10 /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
11 /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
12 /*!40101 SET NAMES utf8 */;
13
14 --
15 -- Database: icinga
16 --
17
18 -- --------------------------------------------------------
19
20 --
21 -- Table structure for table icinga_acknowledgements
22 --
23
24 CREATE TABLE IF NOT EXISTS icinga_acknowledgements (
25   acknowledgement_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
26   instance_id bigint unsigned default 0,
27   entry_time timestamp NULL,
28   entry_time_usec  int default 0,
29   acknowledgement_type smallint default 0,
30   object_id bigint unsigned default 0,
31   state smallint default 0,
32   author_name varchar(64) character set latin1  default '',
33   comment_data TEXT character set latin1,
34   is_sticky smallint default 0,
35   persistent_comment smallint default 0,
36   notify_contacts smallint default 0,
37   end_time timestamp NULL,
38   PRIMARY KEY  (acknowledgement_id)
39 ) ENGINE=InnoDB COMMENT='Current and historical host and service acknowledgements';
40
41 -- --------------------------------------------------------
42
43 --
44 -- Table structure for table icinga_commands
45 --
46
47 CREATE TABLE IF NOT EXISTS icinga_commands (
48   command_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
49   instance_id bigint unsigned default 0,
50   config_type smallint default 0,
51   object_id bigint unsigned default 0,
52   command_line TEXT character set latin1,
53   config_hash varchar(64) DEFAULT NULL,
54   PRIMARY KEY  (command_id),
55   UNIQUE KEY instance_id (instance_id,object_id,config_type)
56 ) ENGINE=InnoDB  COMMENT='Command definitions';
57
58 -- --------------------------------------------------------
59
60 --
61 -- Table structure for table icinga_commenthistory
62 --
63
64 CREATE TABLE IF NOT EXISTS icinga_commenthistory (
65   commenthistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
66   instance_id bigint unsigned default 0,
67   entry_time timestamp NULL,
68   entry_time_usec  int default 0,
69   comment_type smallint default 0,
70   entry_type smallint default 0,
71   object_id bigint unsigned default 0,
72   comment_time timestamp NULL,
73   internal_comment_id bigint unsigned default 0,
74   author_name varchar(64) character set latin1  default '',
75   comment_data TEXT character set latin1,
76   is_persistent smallint default 0,
77   comment_source smallint default 0,
78   expires smallint default 0,
79   expiration_time timestamp NULL,
80   deletion_time timestamp NULL,
81   deletion_time_usec  int default 0,
82   name TEXT character set latin1 default NULL,
83   PRIMARY KEY  (commenthistory_id),
84   UNIQUE KEY instance_id (instance_id,object_id,comment_time,internal_comment_id)
85 ) ENGINE=InnoDB  COMMENT='Historical host and service comments';
86
87 -- --------------------------------------------------------
88
89 --
90 -- Table structure for table icinga_comments
91 --
92
93 CREATE TABLE IF NOT EXISTS icinga_comments (
94   comment_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
95   instance_id bigint unsigned default 0,
96   entry_time timestamp NULL,
97   entry_time_usec  int default 0,
98   comment_type smallint default 0,
99   entry_type smallint default 0,
100   object_id bigint unsigned default 0,
101   comment_time timestamp NULL,
102   internal_comment_id bigint unsigned default 0,
103   author_name varchar(64) character set latin1  default '',
104   comment_data TEXT character set latin1,
105   is_persistent smallint default 0,
106   comment_source smallint default 0,
107   expires smallint default 0,
108   expiration_time timestamp NULL,
109   name TEXT character set latin1 default NULL,
110   session_token int default NULL,
111   PRIMARY KEY  (comment_id),
112   UNIQUE KEY instance_id (instance_id,object_id,comment_time,internal_comment_id)
113 ) ENGINE=InnoDB  COMMENT='Usercomments on Icinga objects';
114
115 -- --------------------------------------------------------
116
117 --
118 -- Table structure for table icinga_configfiles
119 --
120
121 CREATE TABLE IF NOT EXISTS icinga_configfiles (
122   configfile_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
123   instance_id bigint unsigned default 0,
124   configfile_type smallint default 0,
125   configfile_path varchar(255) character set latin1  default '',
126   PRIMARY KEY  (configfile_id),
127   UNIQUE KEY instance_id (instance_id,configfile_type,configfile_path)
128 ) ENGINE=InnoDB  COMMENT='Configuration files';
129
130 -- --------------------------------------------------------
131
132 --
133 -- Table structure for table icinga_configfilevariables
134 --
135
136 CREATE TABLE IF NOT EXISTS icinga_configfilevariables (
137   configfilevariable_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
138   instance_id bigint unsigned default 0,
139   configfile_id bigint unsigned default 0,
140   varname varchar(64) character set latin1  default '',
141   varvalue TEXT character set latin1,
142   PRIMARY KEY  (configfilevariable_id)
143 ) ENGINE=InnoDB  COMMENT='Configuration file variables';
144
145 -- --------------------------------------------------------
146
147 --
148 -- Table structure for table icinga_conninfo
149 --
150
151 CREATE TABLE IF NOT EXISTS icinga_conninfo (
152   conninfo_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
153   instance_id bigint unsigned default 0,
154   agent_name varchar(32) character set latin1  default '',
155   agent_version varchar(32) character set latin1  default '',
156   disposition varchar(32) character set latin1  default '',
157   connect_source varchar(32) character set latin1  default '',
158   connect_type varchar(32) character set latin1  default '',
159   connect_time timestamp NULL,
160   disconnect_time timestamp NULL,
161   last_checkin_time timestamp NULL,
162   data_start_time timestamp NULL,
163   data_end_time timestamp NULL,
164   bytes_processed bigint unsigned  default '0',
165   lines_processed bigint unsigned  default '0',
166   entries_processed bigint unsigned  default '0',
167   PRIMARY KEY  (conninfo_id)
168 ) ENGINE=InnoDB  COMMENT='IDO2DB daemon connection information';
169
170 -- --------------------------------------------------------
171
172 --
173 -- Table structure for table icinga_contactgroups
174 --
175
176 CREATE TABLE IF NOT EXISTS icinga_contactgroups (
177   contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
178   instance_id bigint unsigned default 0,
179   config_type smallint default 0,
180   contactgroup_object_id bigint unsigned default 0,
181   alias varchar(255) character set latin1  default '',
182   config_hash varchar(64) DEFAULT NULL,
183   PRIMARY KEY  (contactgroup_id),
184   UNIQUE KEY instance_id (instance_id,config_type,contactgroup_object_id)
185 ) ENGINE=InnoDB  COMMENT='Contactgroup definitions';
186
187 -- --------------------------------------------------------
188
189 --
190 -- Table structure for table icinga_contactgroup_members
191 --
192
193 CREATE TABLE IF NOT EXISTS icinga_contactgroup_members (
194   contactgroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
195   instance_id bigint unsigned default 0,
196   contactgroup_id bigint unsigned default 0,
197   contact_object_id bigint unsigned default 0,
198   PRIMARY KEY  (contactgroup_member_id)
199 ) ENGINE=InnoDB  COMMENT='Contactgroup members';
200
201 -- --------------------------------------------------------
202
203 --
204 -- Table structure for table icinga_contactnotificationmethods
205 --
206
207 CREATE TABLE IF NOT EXISTS icinga_contactnotificationmethods (
208   contactnotificationmethod_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
209   instance_id bigint unsigned default 0,
210   contactnotification_id bigint unsigned default 0,
211   start_time timestamp NULL,
212   start_time_usec  int default 0,
213   end_time timestamp NULL,
214   end_time_usec  int default 0,
215   command_object_id bigint unsigned default 0,
216   command_args TEXT character set latin1,
217   PRIMARY KEY  (contactnotificationmethod_id),
218   UNIQUE KEY instance_id (instance_id,contactnotification_id,start_time,start_time_usec)
219 ) ENGINE=InnoDB  COMMENT='Historical record of contact notification methods';
220
221 -- --------------------------------------------------------
222
223 --
224 -- Table structure for table icinga_contactnotifications
225 --
226
227 CREATE TABLE IF NOT EXISTS icinga_contactnotifications (
228   contactnotification_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
229   instance_id bigint unsigned default 0,
230   notification_id bigint unsigned default 0,
231   contact_object_id bigint unsigned default 0,
232   start_time timestamp NULL,
233   start_time_usec  int default 0,
234   end_time timestamp NULL,
235   end_time_usec  int default 0,
236   PRIMARY KEY  (contactnotification_id),
237   UNIQUE KEY instance_id (instance_id,contact_object_id,start_time,start_time_usec)
238 ) ENGINE=InnoDB  COMMENT='Historical record of contact notifications';
239
240 -- --------------------------------------------------------
241
242 --
243 -- Table structure for table icinga_contacts
244 --
245
246 CREATE TABLE IF NOT EXISTS icinga_contacts (
247   contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
248   instance_id bigint unsigned default 0,
249   config_type smallint default 0,
250   contact_object_id bigint unsigned default 0,
251   alias varchar(255) character set latin1  default '',
252   email_address varchar(255) character set latin1  default '',
253   pager_address varchar(64) character set latin1  default '',
254   host_timeperiod_object_id bigint unsigned default 0,
255   service_timeperiod_object_id bigint unsigned default 0,
256   host_notifications_enabled smallint default 0,
257   service_notifications_enabled smallint default 0,
258   can_submit_commands smallint default 0,
259   notify_service_recovery smallint default 0,
260   notify_service_warning smallint default 0,
261   notify_service_unknown smallint default 0,
262   notify_service_critical smallint default 0,
263   notify_service_flapping smallint default 0,
264   notify_service_downtime smallint default 0,
265   notify_host_recovery smallint default 0,
266   notify_host_down smallint default 0,
267   notify_host_unreachable smallint default 0,
268   notify_host_flapping smallint default 0,
269   notify_host_downtime smallint default 0,
270   config_hash varchar(64) DEFAULT NULL,
271   PRIMARY KEY  (contact_id),
272   UNIQUE KEY instance_id (instance_id,config_type,contact_object_id)
273 ) ENGINE=InnoDB  COMMENT='Contact definitions';
274
275 -- --------------------------------------------------------
276
277 --
278 -- Table structure for table icinga_contactstatus
279 --
280
281 CREATE TABLE IF NOT EXISTS icinga_contactstatus (
282   contactstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
283   instance_id bigint unsigned default 0,
284   contact_object_id bigint unsigned default 0,
285   status_update_time timestamp NULL,
286   host_notifications_enabled smallint default 0,
287   service_notifications_enabled smallint default 0,
288   last_host_notification timestamp NULL,
289   last_service_notification timestamp NULL,
290   modified_attributes  int default 0,
291   modified_host_attributes  int default 0,
292   modified_service_attributes  int default 0,
293   PRIMARY KEY  (contactstatus_id),
294   UNIQUE KEY contact_object_id (contact_object_id)
295 ) ENGINE=InnoDB  COMMENT='Contact status';
296
297 -- --------------------------------------------------------
298
299 --
300 -- Table structure for table icinga_contact_addresses
301 --
302
303 CREATE TABLE IF NOT EXISTS icinga_contact_addresses (
304   contact_address_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
305   instance_id bigint unsigned default 0,
306   contact_id bigint unsigned default 0,
307   address_number smallint default 0,
308   address varchar(255) character set latin1  default '',
309   PRIMARY KEY  (contact_address_id),
310   UNIQUE KEY contact_id (contact_id,address_number)
311 ) ENGINE=InnoDB COMMENT='Contact addresses';
312
313 -- --------------------------------------------------------
314
315 --
316 -- Table structure for table icinga_contact_notificationcommands
317 --
318
319 CREATE TABLE IF NOT EXISTS icinga_contact_notificationcommands (
320   contact_notificationcommand_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
321   instance_id bigint unsigned default 0,
322   contact_id bigint unsigned default 0,
323   notification_type smallint default 0,
324   command_object_id bigint unsigned default 0,
325   command_args varchar(255) character set latin1  default '',
326   PRIMARY KEY  (contact_notificationcommand_id),
327   UNIQUE KEY contact_id (contact_id,notification_type,command_object_id,command_args)
328 ) ENGINE=InnoDB  COMMENT='Contact host and service notification commands';
329
330 -- --------------------------------------------------------
331
332 --
333 -- Table structure for table icinga_customvariables
334 --
335
336 CREATE TABLE IF NOT EXISTS icinga_customvariables (
337   customvariable_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
338   instance_id bigint unsigned default 0,
339   object_id bigint unsigned default 0,
340   config_type smallint default 0,
341   has_been_modified smallint default 0,
342   varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
343   varvalue TEXT character set latin1,
344   is_json smallint default 0,
345   PRIMARY KEY  (customvariable_id),
346   UNIQUE KEY object_id_2 (object_id,config_type,varname),
347   KEY varname (varname)
348 ) ENGINE=InnoDB COMMENT='Custom variables';
349
350 -- --------------------------------------------------------
351
352 --
353 -- Table structure for table icinga_customvariablestatus
354 --
355
356 CREATE TABLE IF NOT EXISTS icinga_customvariablestatus (
357   customvariablestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
358   instance_id bigint unsigned default 0,
359   object_id bigint unsigned default 0,
360   status_update_time timestamp NULL,
361   has_been_modified smallint default 0,
362   varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
363   varvalue TEXT character set latin1,
364   is_json smallint default 0,
365   PRIMARY KEY  (customvariablestatus_id),
366   UNIQUE KEY object_id_2 (object_id,varname),
367   KEY varname (varname)
368 ) ENGINE=InnoDB COMMENT='Custom variable status information';
369
370 -- --------------------------------------------------------
371
372 --
373 -- Table structure for table icinga_dbversion
374 --
375
376 CREATE TABLE IF NOT EXISTS icinga_dbversion (
377   dbversion_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
378   name varchar(10) character set latin1  default '',
379   version varchar(10) character set latin1  default '',
380   create_time timestamp NULL,
381   modify_time timestamp NULL,
382   PRIMARY KEY (dbversion_id),
383   UNIQUE KEY dbversion (name)
384 ) ENGINE=InnoDB;
385
386 -- --------------------------------------------------------
387
388 --
389 -- Table structure for table icinga_downtimehistory
390 --
391
392 CREATE TABLE IF NOT EXISTS icinga_downtimehistory (
393   downtimehistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
394   instance_id bigint unsigned default 0,
395   downtime_type smallint default 0,
396   object_id bigint unsigned default 0,
397   entry_time timestamp NULL,
398   author_name varchar(64) character set latin1  default '',
399   comment_data TEXT character set latin1,
400   internal_downtime_id bigint unsigned default 0,
401   triggered_by_id bigint unsigned default 0,
402   is_fixed smallint default 0,
403   duration bigint(20) default 0,
404   scheduled_start_time timestamp NULL,
405   scheduled_end_time timestamp NULL,
406   was_started smallint default 0,
407   actual_start_time timestamp NULL,
408   actual_start_time_usec  int default 0,
409   actual_end_time timestamp NULL,
410   actual_end_time_usec  int default 0,
411   was_cancelled smallint default 0,
412   is_in_effect smallint default 0,
413   trigger_time timestamp NULL,
414   name TEXT character set latin1 default NULL,
415   PRIMARY KEY  (downtimehistory_id),
416   UNIQUE KEY instance_id (instance_id,object_id,entry_time,internal_downtime_id)
417 ) ENGINE=InnoDB  COMMENT='Historical scheduled host and service downtime';
418
419 -- --------------------------------------------------------
420
421 --
422 -- Table structure for table icinga_eventhandlers
423 --
424
425 CREATE TABLE IF NOT EXISTS icinga_eventhandlers (
426   eventhandler_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
427   instance_id bigint unsigned default 0,
428   eventhandler_type smallint default 0,
429   object_id bigint unsigned default 0,
430   state smallint default 0,
431   state_type smallint default 0,
432   start_time timestamp NULL,
433   start_time_usec  int default 0,
434   end_time timestamp NULL,
435   end_time_usec  int default 0,
436   command_object_id bigint unsigned default 0,
437   command_args TEXT character set latin1,
438   command_line TEXT character set latin1,
439   timeout smallint default 0,
440   early_timeout smallint default 0,
441   execution_time double  default '0',
442   return_code smallint default 0,
443   output TEXT character set latin1,
444   long_output TEXT,
445   PRIMARY KEY  (eventhandler_id),
446   UNIQUE KEY instance_id (instance_id,object_id,start_time,start_time_usec)
447 ) ENGINE=InnoDB COMMENT='Historical host and service event handlers';
448
449 -- --------------------------------------------------------
450
451 --
452 -- Table structure for table icinga_externalcommands
453 --
454
455 CREATE TABLE IF NOT EXISTS icinga_externalcommands (
456   externalcommand_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
457   instance_id bigint unsigned default 0,
458   entry_time timestamp NULL,
459   command_type smallint default 0,
460   command_name varchar(128) character set latin1  default '',
461   command_args TEXT character set latin1,
462   PRIMARY KEY  (externalcommand_id)
463 ) ENGINE=InnoDB  COMMENT='Historical record of processed external commands';
464
465 -- --------------------------------------------------------
466
467 --
468 -- Table structure for table icinga_flappinghistory
469 --
470
471 CREATE TABLE IF NOT EXISTS icinga_flappinghistory (
472   flappinghistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
473   instance_id bigint unsigned default 0,
474   event_time timestamp NULL,
475   event_time_usec  int default 0,
476   event_type smallint default 0,
477   reason_type smallint default 0,
478   flapping_type smallint default 0,
479   object_id bigint unsigned default 0,
480   percent_state_change double  default '0',
481   low_threshold double  default '0',
482   high_threshold double  default '0',
483   comment_time timestamp NULL,
484   internal_comment_id bigint unsigned default 0,
485   PRIMARY KEY  (flappinghistory_id)
486 ) ENGINE=InnoDB  COMMENT='Current and historical record of host and service flapping';
487
488 -- --------------------------------------------------------
489
490 --
491 -- Table structure for table icinga_hostchecks
492 --
493
494 CREATE TABLE IF NOT EXISTS icinga_hostchecks (
495   hostcheck_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
496   instance_id bigint unsigned default 0,
497   host_object_id bigint unsigned default 0,
498   check_type smallint default 0,
499   is_raw_check smallint default 0,
500   current_check_attempt smallint default 0,
501   max_check_attempts smallint default 0,
502   state smallint default 0,
503   state_type smallint default 0,
504   start_time timestamp NULL,
505   start_time_usec  int default 0,
506   end_time timestamp NULL,
507   end_time_usec  int default 0,
508   command_object_id bigint unsigned default 0,
509   command_args TEXT character set latin1,
510   command_line TEXT character set latin1,
511   timeout smallint default 0,
512   early_timeout smallint default 0,
513   execution_time double  default '0',
514   latency double  default '0',
515   return_code smallint default 0,
516   output TEXT character set latin1,
517   long_output TEXT,
518   perfdata TEXT character set latin1,
519   PRIMARY KEY  (hostcheck_id)
520 ) ENGINE=InnoDB  COMMENT='Historical host checks';
521
522 -- --------------------------------------------------------
523
524 --
525 -- Table structure for table icinga_hostdependencies
526 --
527
528 CREATE TABLE IF NOT EXISTS icinga_hostdependencies (
529   hostdependency_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
530   instance_id bigint unsigned default 0,
531   config_type smallint default 0,
532   host_object_id bigint unsigned default 0,
533   dependent_host_object_id bigint unsigned default 0,
534   dependency_type smallint default 0,
535   inherits_parent smallint default 0,
536   timeperiod_object_id bigint unsigned default 0,
537   fail_on_up smallint default 0,
538   fail_on_down smallint default 0,
539   fail_on_unreachable smallint default 0,
540   PRIMARY KEY  (hostdependency_id),
541   KEY instance_id (instance_id,config_type,host_object_id,dependent_host_object_id,dependency_type,inherits_parent,fail_on_up,fail_on_down,fail_on_unreachable)
542 ) ENGINE=InnoDB COMMENT='Host dependency definitions';
543
544 -- --------------------------------------------------------
545
546 --
547 -- Table structure for table icinga_hostescalations
548 --
549
550 CREATE TABLE IF NOT EXISTS icinga_hostescalations (
551   hostescalation_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
552   instance_id bigint unsigned default 0,
553   config_type smallint default 0,
554   host_object_id bigint unsigned default 0,
555   timeperiod_object_id bigint unsigned default 0,
556   first_notification smallint default 0,
557   last_notification smallint default 0,
558   notification_interval double  default '0',
559   escalate_on_recovery smallint default 0,
560   escalate_on_down smallint default 0,
561   escalate_on_unreachable smallint default 0,
562   PRIMARY KEY  (hostescalation_id),
563   UNIQUE KEY instance_id (instance_id,config_type,host_object_id,timeperiod_object_id,first_notification,last_notification)
564 ) ENGINE=InnoDB  COMMENT='Host escalation definitions';
565
566 -- --------------------------------------------------------
567
568 --
569 -- Table structure for table icinga_hostescalation_contactgroups
570 --
571
572 CREATE TABLE IF NOT EXISTS icinga_hostescalation_contactgroups (
573   hostescalation_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
574   instance_id bigint unsigned default 0,
575   hostescalation_id bigint unsigned default 0,
576   contactgroup_object_id bigint unsigned default 0,
577   PRIMARY KEY  (hostescalation_contactgroup_id),
578   UNIQUE KEY instance_id (hostescalation_id,contactgroup_object_id)
579 ) ENGINE=InnoDB  COMMENT='Host escalation contact groups';
580
581 -- --------------------------------------------------------
582
583 --
584 -- Table structure for table icinga_hostescalation_contacts
585 --
586
587 CREATE TABLE IF NOT EXISTS icinga_hostescalation_contacts (
588   hostescalation_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
589   instance_id bigint unsigned default 0,
590   hostescalation_id bigint unsigned default 0,
591   contact_object_id bigint unsigned default 0,
592   PRIMARY KEY  (hostescalation_contact_id),
593   UNIQUE KEY instance_id (instance_id,hostescalation_id,contact_object_id)
594 ) ENGINE=InnoDB  COMMENT='Host escalation contacts';
595
596 -- --------------------------------------------------------
597
598 --
599 -- Table structure for table icinga_hostgroups
600 --
601
602 CREATE TABLE IF NOT EXISTS icinga_hostgroups (
603   hostgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
604   instance_id bigint unsigned default 0,
605   config_type smallint default 0,
606   hostgroup_object_id bigint unsigned default 0,
607   alias varchar(255) character set latin1  default '',
608   notes TEXT character set latin1  default NULL,
609   notes_url TEXT character set latin1  default NULL,
610   action_url TEXT character set latin1  default NULL,
611   config_hash varchar(64) DEFAULT NULL,
612   PRIMARY KEY  (hostgroup_id),
613   UNIQUE KEY instance_id (instance_id,hostgroup_object_id)
614 ) ENGINE=InnoDB  COMMENT='Hostgroup definitions';
615
616 -- --------------------------------------------------------
617
618 --
619 -- Table structure for table icinga_hostgroup_members
620 --
621
622 CREATE TABLE IF NOT EXISTS icinga_hostgroup_members (
623   hostgroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
624   instance_id bigint unsigned default 0,
625   hostgroup_id bigint unsigned default 0,
626   host_object_id bigint unsigned default 0,
627   PRIMARY KEY  (hostgroup_member_id)
628 ) ENGINE=InnoDB  COMMENT='Hostgroup members';
629
630 -- --------------------------------------------------------
631
632 --
633 -- Table structure for table icinga_hosts
634 --
635
636 CREATE TABLE IF NOT EXISTS icinga_hosts (
637   host_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
638   instance_id bigint unsigned default 0,
639   config_type smallint default 0,
640   host_object_id bigint unsigned default 0,
641   alias varchar(255) character set latin1  default '',
642   display_name varchar(255) character set latin1 collate latin1_general_cs  default '',
643   address varchar(128) character set latin1  default '',
644   address6 varchar(128) character set latin1  default '',
645   check_command_object_id bigint unsigned default 0,
646   check_command_args TEXT character set latin1,
647   eventhandler_command_object_id bigint unsigned default 0,
648   eventhandler_command_args TEXT character set latin1,
649   notification_timeperiod_object_id bigint unsigned default 0,
650   check_timeperiod_object_id bigint unsigned default 0,
651   failure_prediction_options varchar(128) character set latin1  default '',
652   check_interval double  default '0',
653   retry_interval double  default '0',
654   max_check_attempts smallint default 0,
655   first_notification_delay double  default '0',
656   notification_interval double  default '0',
657   notify_on_down smallint default 0,
658   notify_on_unreachable smallint default 0,
659   notify_on_recovery smallint default 0,
660   notify_on_flapping smallint default 0,
661   notify_on_downtime smallint default 0,
662   stalk_on_up smallint default 0,
663   stalk_on_down smallint default 0,
664   stalk_on_unreachable smallint default 0,
665   flap_detection_enabled smallint default 0,
666   flap_detection_on_up smallint default 0,
667   flap_detection_on_down smallint default 0,
668   flap_detection_on_unreachable smallint default 0,
669   low_flap_threshold double  default '0',
670   high_flap_threshold double  default '0',
671   process_performance_data smallint default 0,
672   freshness_checks_enabled smallint default 0,
673   freshness_threshold int default 0,
674   passive_checks_enabled smallint default 0,
675   event_handler_enabled smallint default 0,
676   active_checks_enabled smallint default 0,
677   retain_status_information smallint default 0,
678   retain_nonstatus_information smallint default 0,
679   notifications_enabled smallint default 0,
680   obsess_over_host smallint default 0,
681   failure_prediction_enabled smallint default 0,
682   notes TEXT character set latin1,
683   notes_url TEXT character set latin1,
684   action_url TEXT character set latin1,
685   icon_image TEXT character set latin1,
686   icon_image_alt TEXT character set latin1,
687   vrml_image TEXT character set latin1,
688   statusmap_image TEXT character set latin1,
689   have_2d_coords smallint default 0,
690   x_2d smallint default 0,
691   y_2d smallint default 0,
692   have_3d_coords smallint default 0,
693   x_3d double  default '0',
694   y_3d double  default '0',
695   z_3d double  default '0',
696   config_hash varchar(64) DEFAULT NULL,
697   PRIMARY KEY  (host_id),
698   UNIQUE KEY instance_id (instance_id,config_type,host_object_id),
699   KEY host_object_id (host_object_id)
700 ) ENGINE=InnoDB  COMMENT='Host definitions';
701
702 -- --------------------------------------------------------
703
704 --
705 -- Table structure for table icinga_hoststatus
706 --
707
708 CREATE TABLE IF NOT EXISTS icinga_hoststatus (
709   hoststatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
710   instance_id bigint unsigned default 0,
711   host_object_id bigint unsigned default 0,
712   status_update_time timestamp NULL,
713   output TEXT character set latin1,
714   long_output TEXT,
715   perfdata TEXT character set latin1,
716   check_source varchar(255) character set latin1  default '',
717   current_state smallint default 0,
718   has_been_checked smallint default 0,
719   should_be_scheduled smallint default 0,
720   current_check_attempt smallint default 0,
721   max_check_attempts smallint default 0,
722   last_check timestamp NULL,
723   next_check timestamp NULL,
724   check_type smallint default 0,
725   last_state_change timestamp NULL,
726   last_hard_state_change timestamp NULL,
727   last_hard_state smallint default 0,
728   last_time_up timestamp NULL,
729   last_time_down timestamp NULL,
730   last_time_unreachable timestamp NULL,
731   state_type smallint default 0,
732   last_notification timestamp NULL,
733   next_notification timestamp NULL,
734   no_more_notifications smallint default 0,
735   notifications_enabled smallint default 0,
736   problem_has_been_acknowledged smallint default 0,
737   acknowledgement_type smallint default 0,
738   current_notification_number int unsigned default 0,
739   passive_checks_enabled smallint default 0,
740   active_checks_enabled smallint default 0,
741   event_handler_enabled smallint default 0,
742   flap_detection_enabled smallint default 0,
743   is_flapping smallint default 0,
744   percent_state_change double  default '0',
745   latency double  default '0',
746   execution_time double  default '0',
747   scheduled_downtime_depth smallint default 0,
748   failure_prediction_enabled smallint default 0,
749   process_performance_data smallint default 0,
750   obsess_over_host smallint default 0,
751   modified_host_attributes  int default 0,
752   original_attributes TEXT character set latin1  default NULL,
753   event_handler TEXT character set latin1,
754   check_command TEXT character set latin1,
755   normal_check_interval double  default '0',
756   retry_check_interval double  default '0',
757   check_timeperiod_object_id bigint unsigned default 0,
758   is_reachable smallint default 0,
759   PRIMARY KEY  (hoststatus_id),
760   UNIQUE KEY object_id (host_object_id)
761 ) ENGINE=InnoDB  COMMENT='Current host status information';
762
763 -- --------------------------------------------------------
764
765 --
766 -- Table structure for table icinga_host_contactgroups
767 --
768
769 CREATE TABLE IF NOT EXISTS icinga_host_contactgroups (
770   host_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
771   instance_id bigint unsigned default 0,
772   host_id bigint unsigned default 0,
773   contactgroup_object_id bigint unsigned default 0,
774   PRIMARY KEY  (host_contactgroup_id)
775 ) ENGINE=InnoDB  COMMENT='Host contact groups';
776
777 -- --------------------------------------------------------
778
779 --
780 -- Table structure for table icinga_host_contacts
781 --
782
783 CREATE TABLE IF NOT EXISTS icinga_host_contacts (
784   host_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
785   instance_id bigint unsigned default 0,
786   host_id bigint unsigned default 0,
787   contact_object_id bigint unsigned default 0,
788   PRIMARY KEY  (host_contact_id)
789 ) ENGINE=InnoDB  COMMENT='Host contacts';
790
791 -- --------------------------------------------------------
792
793 --
794 -- Table structure for table icinga_host_parenthosts
795 --
796
797 CREATE TABLE IF NOT EXISTS icinga_host_parenthosts (
798   host_parenthost_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
799   instance_id bigint unsigned default 0,
800   host_id bigint unsigned default 0,
801   parent_host_object_id bigint unsigned default 0,
802   PRIMARY KEY  (host_parenthost_id)
803 ) ENGINE=InnoDB  COMMENT='Parent hosts';
804
805 -- --------------------------------------------------------
806
807 --
808 -- Table structure for table icinga_instances
809 --
810
811 CREATE TABLE IF NOT EXISTS icinga_instances (
812   instance_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
813   instance_name varchar(64) character set latin1  default '',
814   instance_description varchar(128) character set latin1  default '',
815   PRIMARY KEY  (instance_id)
816 ) ENGINE=InnoDB  COMMENT='Location names of various Icinga installations';
817
818 -- --------------------------------------------------------
819
820 --
821 -- Table structure for table icinga_logentries
822 --
823
824 CREATE TABLE IF NOT EXISTS icinga_logentries (
825   logentry_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
826   instance_id bigint unsigned default 0,
827   logentry_time timestamp NULL,
828   entry_time timestamp NULL,
829   entry_time_usec  int default 0,
830   logentry_type  int default 0,
831   logentry_data TEXT character set latin1,
832   realtime_data smallint default 0,
833   inferred_data_extracted smallint default 0,
834   object_id bigint unsigned default NULL,
835   PRIMARY KEY  (logentry_id)
836 ) ENGINE=InnoDB COMMENT='Historical record of log entries';
837
838 -- --------------------------------------------------------
839
840 --
841 -- Table structure for table icinga_notifications
842 --
843
844 CREATE TABLE IF NOT EXISTS icinga_notifications (
845   notification_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
846   instance_id bigint unsigned default 0,
847   notification_type smallint default 0,
848   notification_reason smallint default 0,
849   object_id bigint unsigned default 0,
850   start_time timestamp NULL,
851   start_time_usec  int default 0,
852   end_time timestamp NULL,
853   end_time_usec  int default 0,
854   state smallint default 0,
855   output TEXT character set latin1,
856   long_output TEXT,
857   escalated smallint default 0,
858   contacts_notified smallint default 0,
859   PRIMARY KEY  (notification_id),
860   UNIQUE KEY instance_id (instance_id,object_id,start_time,start_time_usec)
861 ) ENGINE=InnoDB  COMMENT='Historical record of host and service notifications';
862
863 -- --------------------------------------------------------
864
865 --
866 -- Table structure for table icinga_objects
867 --
868
869 CREATE TABLE IF NOT EXISTS icinga_objects (
870   object_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
871   instance_id bigint unsigned default 0,
872   objecttype_id bigint unsigned default 0,
873   name1 varchar(128) character set latin1 collate latin1_general_cs  default '',
874   name2 varchar(128) character set latin1 collate latin1_general_cs default NULL,
875   is_active smallint default 0,
876   PRIMARY KEY  (object_id),
877   KEY objecttype_id (objecttype_id,name1,name2)
878 ) ENGINE=InnoDB  COMMENT='Current and historical objects of all kinds';
879
880 -- --------------------------------------------------------
881
882 --
883 -- Table structure for table icinga_processevents
884 --
885
886 CREATE TABLE IF NOT EXISTS icinga_processevents (
887   processevent_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
888   instance_id bigint unsigned default 0,
889   event_type smallint default 0,
890   event_time timestamp NULL,
891   event_time_usec  int default 0,
892   process_id bigint unsigned default 0,
893   program_name varchar(16) character set latin1  default '',
894   program_version varchar(20) character set latin1  default '',
895   program_date varchar(10) character set latin1  default '',
896   PRIMARY KEY  (processevent_id)
897 ) ENGINE=InnoDB  COMMENT='Historical Icinga process events';
898
899 -- --------------------------------------------------------
900
901 --
902 -- Table structure for table icinga_programstatus
903 --
904
905 CREATE TABLE IF NOT EXISTS icinga_programstatus (
906   programstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
907   instance_id bigint unsigned default 0,
908   program_version varchar(64) character set latin1 collate latin1_general_cs default NULL,
909   status_update_time timestamp NULL,
910   program_start_time timestamp NULL,
911   program_end_time timestamp NULL,
912   endpoint_name varchar(255) character set latin1 collate latin1_general_cs default NULL,
913   is_currently_running smallint default 0,
914   process_id bigint unsigned default 0,
915   daemon_mode smallint default 0,
916   last_command_check timestamp NULL,
917   last_log_rotation timestamp NULL,
918   notifications_enabled smallint default 0,
919   disable_notif_expire_time timestamp NULL,
920   active_service_checks_enabled smallint default 0,
921   passive_service_checks_enabled smallint default 0,
922   active_host_checks_enabled smallint default 0,
923   passive_host_checks_enabled smallint default 0,
924   event_handlers_enabled smallint default 0,
925   flap_detection_enabled smallint default 0,
926   failure_prediction_enabled smallint default 0,
927   process_performance_data smallint default 0,
928   obsess_over_hosts smallint default 0,
929   obsess_over_services smallint default 0,
930   modified_host_attributes  int default 0,
931   modified_service_attributes  int default 0,
932   global_host_event_handler TEXT character set latin1,
933   global_service_event_handler TEXT character set latin1,
934   config_dump_in_progress smallint default 0,
935   PRIMARY KEY  (programstatus_id),
936   UNIQUE KEY instance_id (instance_id)
937 ) ENGINE=InnoDB  COMMENT='Current program status information';
938
939 -- --------------------------------------------------------
940
941 --
942 -- Table structure for table icinga_runtimevariables
943 --
944
945 CREATE TABLE IF NOT EXISTS icinga_runtimevariables (
946   runtimevariable_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
947   instance_id bigint unsigned default 0,
948   varname varchar(64) character set latin1  default '',
949   varvalue TEXT character set latin1,
950   PRIMARY KEY  (runtimevariable_id)
951 ) ENGINE=InnoDB  COMMENT='Runtime variables from the Icinga daemon';
952
953 -- --------------------------------------------------------
954
955 --
956 -- Table structure for table icinga_scheduleddowntime
957 --
958
959 CREATE TABLE IF NOT EXISTS icinga_scheduleddowntime (
960   scheduleddowntime_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
961   instance_id bigint unsigned default 0,
962   downtime_type smallint default 0,
963   object_id bigint unsigned default 0,
964   entry_time timestamp NULL,
965   author_name varchar(64) character set latin1  default '',
966   comment_data TEXT character set latin1,
967   internal_downtime_id bigint unsigned default 0,
968   triggered_by_id bigint unsigned default 0,
969   is_fixed smallint default 0,
970   duration bigint(20) default 0,
971   scheduled_start_time timestamp NULL,
972   scheduled_end_time timestamp NULL,
973   was_started smallint default 0,
974   actual_start_time timestamp NULL,
975   actual_start_time_usec  int default 0,
976   is_in_effect smallint default 0,
977   trigger_time timestamp NULL,
978   name TEXT character set latin1 default NULL,
979   session_token int default NULL,
980   PRIMARY KEY  (scheduleddowntime_id),
981   UNIQUE KEY instance_id (instance_id,object_id,entry_time,internal_downtime_id)
982 ) ENGINE=InnoDB COMMENT='Current scheduled host and service downtime';
983
984 -- --------------------------------------------------------
985
986 --
987 -- Table structure for table icinga_servicechecks
988 --
989
990 CREATE TABLE IF NOT EXISTS icinga_servicechecks (
991   servicecheck_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
992   instance_id bigint unsigned default 0,
993   service_object_id bigint unsigned default 0,
994   check_type smallint default 0,
995   current_check_attempt smallint default 0,
996   max_check_attempts smallint default 0,
997   state smallint default 0,
998   state_type smallint default 0,
999   start_time timestamp NULL,
1000   start_time_usec  int default 0,
1001   end_time timestamp NULL,
1002   end_time_usec  int default 0,
1003   command_object_id bigint unsigned default 0,
1004   command_args TEXT character set latin1,
1005   command_line TEXT character set latin1,
1006   timeout smallint default 0,
1007   early_timeout smallint default 0,
1008   execution_time double  default '0',
1009   latency double  default '0',
1010   return_code smallint default 0,
1011   output TEXT character set latin1,
1012   long_output TEXT,
1013   perfdata TEXT character set latin1,
1014   PRIMARY KEY  (servicecheck_id)
1015 ) ENGINE=InnoDB  COMMENT='Historical service checks';
1016
1017 -- --------------------------------------------------------
1018
1019 --
1020 -- Table structure for table icinga_servicedependencies
1021 --
1022
1023 CREATE TABLE IF NOT EXISTS icinga_servicedependencies (
1024   servicedependency_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1025   instance_id bigint unsigned default 0,
1026   config_type smallint default 0,
1027   service_object_id bigint unsigned default 0,
1028   dependent_service_object_id bigint unsigned default 0,
1029   dependency_type smallint default 0,
1030   inherits_parent smallint default 0,
1031   timeperiod_object_id bigint unsigned default 0,
1032   fail_on_ok smallint default 0,
1033   fail_on_warning smallint default 0,
1034   fail_on_unknown smallint default 0,
1035   fail_on_critical smallint default 0,
1036   PRIMARY KEY  (servicedependency_id),
1037   KEY instance_id (instance_id,config_type,service_object_id,dependent_service_object_id,dependency_type,inherits_parent,fail_on_ok,fail_on_warning,fail_on_unknown,fail_on_critical)
1038 ) ENGINE=InnoDB COMMENT='Service dependency definitions';
1039
1040 -- --------------------------------------------------------
1041
1042 --
1043 -- Table structure for table icinga_serviceescalations
1044 --
1045
1046 CREATE TABLE IF NOT EXISTS icinga_serviceescalations (
1047   serviceescalation_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1048   instance_id bigint unsigned default 0,
1049   config_type smallint default 0,
1050   service_object_id bigint unsigned default 0,
1051   timeperiod_object_id bigint unsigned default 0,
1052   first_notification smallint default 0,
1053   last_notification smallint default 0,
1054   notification_interval double  default '0',
1055   escalate_on_recovery smallint default 0,
1056   escalate_on_warning smallint default 0,
1057   escalate_on_unknown smallint default 0,
1058   escalate_on_critical smallint default 0,
1059   PRIMARY KEY  (serviceescalation_id),
1060   UNIQUE KEY instance_id (instance_id,config_type,service_object_id,timeperiod_object_id,first_notification,last_notification)
1061 ) ENGINE=InnoDB  COMMENT='Service escalation definitions';
1062
1063 -- --------------------------------------------------------
1064
1065 --
1066 -- Table structure for table icinga_serviceescalation_contactgroups
1067 --
1068
1069 CREATE TABLE IF NOT EXISTS icinga_serviceescalation_contactgroups (
1070   serviceescalation_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1071   instance_id bigint unsigned default 0,
1072   serviceescalation_id bigint unsigned default 0,
1073   contactgroup_object_id bigint unsigned default 0,
1074   PRIMARY KEY  (serviceescalation_contactgroup_id),
1075   UNIQUE KEY instance_id (serviceescalation_id,contactgroup_object_id)
1076 ) ENGINE=InnoDB  COMMENT='Service escalation contact groups';
1077
1078 -- --------------------------------------------------------
1079
1080 --
1081 -- Table structure for table icinga_serviceescalation_contacts
1082 --
1083
1084 CREATE TABLE IF NOT EXISTS icinga_serviceescalation_contacts (
1085   serviceescalation_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1086   instance_id bigint unsigned default 0,
1087   serviceescalation_id bigint unsigned default 0,
1088   contact_object_id bigint unsigned default 0,
1089   PRIMARY KEY  (serviceescalation_contact_id),
1090   UNIQUE KEY instance_id (instance_id,serviceescalation_id,contact_object_id)
1091 ) ENGINE=InnoDB  COMMENT='Service escalation contacts';
1092
1093 -- --------------------------------------------------------
1094
1095 --
1096 -- Table structure for table icinga_servicegroups
1097 --
1098
1099 CREATE TABLE IF NOT EXISTS icinga_servicegroups (
1100   servicegroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1101   instance_id bigint unsigned default 0,
1102   config_type smallint default 0,
1103   servicegroup_object_id bigint unsigned default 0,
1104   alias varchar(255) character set latin1  default '',
1105   notes TEXT character set latin1  default NULL,
1106   notes_url TEXT character set latin1  default NULL,
1107   action_url TEXT character set latin1  default NULL,
1108   config_hash varchar(64) DEFAULT NULL,
1109   PRIMARY KEY  (servicegroup_id),
1110   UNIQUE KEY instance_id (instance_id,config_type,servicegroup_object_id)
1111 ) ENGINE=InnoDB  COMMENT='Servicegroup definitions';
1112
1113 -- --------------------------------------------------------
1114
1115 --
1116 -- Table structure for table icinga_servicegroup_members
1117 --
1118
1119 CREATE TABLE IF NOT EXISTS icinga_servicegroup_members (
1120   servicegroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1121   instance_id bigint unsigned default 0,
1122   servicegroup_id bigint unsigned default 0,
1123   service_object_id bigint unsigned default 0,
1124   PRIMARY KEY  (servicegroup_member_id)
1125 ) ENGINE=InnoDB  COMMENT='Servicegroup members';
1126
1127 -- --------------------------------------------------------
1128
1129 --
1130 -- Table structure for table icinga_services
1131 --
1132
1133 CREATE TABLE IF NOT EXISTS icinga_services (
1134   service_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1135   instance_id bigint unsigned default 0,
1136   config_type smallint default 0,
1137   host_object_id bigint unsigned default 0,
1138   service_object_id bigint unsigned default 0,
1139   display_name varchar(255) character set latin1 collate latin1_general_cs  default '',
1140   check_command_object_id bigint unsigned default 0,
1141   check_command_args TEXT character set latin1,
1142   eventhandler_command_object_id bigint unsigned default 0,
1143   eventhandler_command_args TEXT character set latin1,
1144   notification_timeperiod_object_id bigint unsigned default 0,
1145   check_timeperiod_object_id bigint unsigned default 0,
1146   failure_prediction_options varchar(64) character set latin1  default '',
1147   check_interval double  default '0',
1148   retry_interval double  default '0',
1149   max_check_attempts smallint default 0,
1150   first_notification_delay double  default '0',
1151   notification_interval double  default '0',
1152   notify_on_warning smallint default 0,
1153   notify_on_unknown smallint default 0,
1154   notify_on_critical smallint default 0,
1155   notify_on_recovery smallint default 0,
1156   notify_on_flapping smallint default 0,
1157   notify_on_downtime smallint default 0,
1158   stalk_on_ok smallint default 0,
1159   stalk_on_warning smallint default 0,
1160   stalk_on_unknown smallint default 0,
1161   stalk_on_critical smallint default 0,
1162   is_volatile smallint default 0,
1163   flap_detection_enabled smallint default 0,
1164   flap_detection_on_ok smallint default 0,
1165   flap_detection_on_warning smallint default 0,
1166   flap_detection_on_unknown smallint default 0,
1167   flap_detection_on_critical smallint default 0,
1168   low_flap_threshold double  default '0',
1169   high_flap_threshold double  default '0',
1170   process_performance_data smallint default 0,
1171   freshness_checks_enabled smallint default 0,
1172   freshness_threshold int default 0,
1173   passive_checks_enabled smallint default 0,
1174   event_handler_enabled smallint default 0,
1175   active_checks_enabled smallint default 0,
1176   retain_status_information smallint default 0,
1177   retain_nonstatus_information smallint default 0,
1178   notifications_enabled smallint default 0,
1179   obsess_over_service smallint default 0,
1180   failure_prediction_enabled smallint default 0,
1181   notes TEXT character set latin1,
1182   notes_url TEXT character set latin1,
1183   action_url TEXT character set latin1,
1184   icon_image TEXT character set latin1,
1185   icon_image_alt TEXT character set latin1,
1186   config_hash varchar(64) DEFAULT NULL,
1187   PRIMARY KEY  (service_id),
1188   UNIQUE KEY instance_id (instance_id,config_type,service_object_id),
1189   KEY service_object_id (service_object_id)
1190 ) ENGINE=InnoDB  COMMENT='Service definitions';
1191
1192 -- --------------------------------------------------------
1193
1194 --
1195 -- Table structure for table icinga_servicestatus
1196 --
1197
1198 CREATE TABLE IF NOT EXISTS icinga_servicestatus (
1199   servicestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1200   instance_id bigint unsigned default 0,
1201   service_object_id bigint unsigned default 0,
1202   status_update_time timestamp NULL,
1203   output TEXT character set latin1,
1204   long_output TEXT,
1205   perfdata TEXT character set latin1,
1206   check_source varchar(255) character set latin1  default '',
1207   current_state smallint default 0,
1208   has_been_checked smallint default 0,
1209   should_be_scheduled smallint default 0,
1210   current_check_attempt smallint default 0,
1211   max_check_attempts smallint default 0,
1212   last_check timestamp NULL,
1213   next_check timestamp NULL,
1214   check_type smallint default 0,
1215   last_state_change timestamp NULL,
1216   last_hard_state_change timestamp NULL,
1217   last_hard_state smallint default 0,
1218   last_time_ok timestamp NULL,
1219   last_time_warning timestamp NULL,
1220   last_time_unknown timestamp NULL,
1221   last_time_critical timestamp NULL,
1222   state_type smallint default 0,
1223   last_notification timestamp NULL,
1224   next_notification timestamp NULL,
1225   no_more_notifications smallint default 0,
1226   notifications_enabled smallint default 0,
1227   problem_has_been_acknowledged smallint default 0,
1228   acknowledgement_type smallint default 0,
1229   current_notification_number int unsigned default 0,
1230   passive_checks_enabled smallint default 0,
1231   active_checks_enabled smallint default 0,
1232   event_handler_enabled smallint default 0,
1233   flap_detection_enabled smallint default 0,
1234   is_flapping smallint default 0,
1235   percent_state_change double  default '0',
1236   latency double  default '0',
1237   execution_time double  default '0',
1238   scheduled_downtime_depth smallint default 0,
1239   failure_prediction_enabled smallint default 0,
1240   process_performance_data smallint default 0,
1241   obsess_over_service smallint default 0,
1242   modified_service_attributes  int default 0,
1243   original_attributes TEXT character set latin1  default NULL,
1244   event_handler TEXT character set latin1,
1245   check_command TEXT character set latin1,
1246   normal_check_interval double  default '0',
1247   retry_check_interval double  default '0',
1248   check_timeperiod_object_id bigint unsigned default 0,
1249   is_reachable smallint default 0,
1250   PRIMARY KEY  (servicestatus_id),
1251   UNIQUE KEY object_id (service_object_id)
1252 ) ENGINE=InnoDB  COMMENT='Current service status information';
1253
1254 -- --------------------------------------------------------
1255
1256 --
1257 -- Table structure for table icinga_service_contactgroups
1258 --
1259
1260 CREATE TABLE IF NOT EXISTS icinga_service_contactgroups (
1261   service_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1262   instance_id bigint unsigned default 0,
1263   service_id bigint unsigned default 0,
1264   contactgroup_object_id bigint unsigned default 0,
1265   PRIMARY KEY  (service_contactgroup_id)
1266 ) ENGINE=InnoDB  COMMENT='Service contact groups';
1267
1268 -- --------------------------------------------------------
1269
1270 --
1271 -- Table structure for table icinga_service_contacts
1272 --
1273
1274 CREATE TABLE IF NOT EXISTS icinga_service_contacts (
1275   service_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1276   instance_id bigint unsigned default 0,
1277   service_id bigint unsigned default 0,
1278   contact_object_id bigint unsigned default 0,
1279   PRIMARY KEY  (service_contact_id)
1280 ) ENGINE=InnoDB  COMMENT='Service contacts';
1281
1282 -- --------------------------------------------------------
1283
1284 --
1285 -- Table structure for table icinga_statehistory
1286 --
1287
1288 CREATE TABLE IF NOT EXISTS icinga_statehistory (
1289   statehistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1290   instance_id bigint unsigned default 0,
1291   state_time timestamp NULL,
1292   state_time_usec  int default 0,
1293   object_id bigint unsigned default 0,
1294   state_change smallint default 0,
1295   state smallint default 0,
1296   state_type smallint default 0,
1297   current_check_attempt smallint default 0,
1298   max_check_attempts smallint default 0,
1299   last_state smallint default 0,
1300   last_hard_state smallint default 0,
1301   output TEXT character set latin1,
1302   long_output TEXT,
1303   check_source varchar(255) character set latin1 default NULL,
1304   PRIMARY KEY  (statehistory_id)
1305 ) ENGINE=InnoDB COMMENT='Historical host and service state changes';
1306
1307 -- --------------------------------------------------------
1308
1309 --
1310 -- Table structure for table icinga_systemcommands
1311 --
1312
1313 CREATE TABLE IF NOT EXISTS icinga_systemcommands (
1314   systemcommand_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1315   instance_id bigint unsigned default 0,
1316   start_time timestamp NULL,
1317   start_time_usec  int default 0,
1318   end_time timestamp NULL,
1319   end_time_usec  int default 0,
1320   command_line TEXT character set latin1,
1321   timeout smallint default 0,
1322   early_timeout smallint default 0,
1323   execution_time double  default '0',
1324   return_code smallint default 0,
1325   output TEXT character set latin1,
1326   long_output TEXT,
1327   PRIMARY KEY  (systemcommand_id),
1328   UNIQUE KEY instance_id (instance_id,start_time,start_time_usec)
1329 ) ENGINE=InnoDB  COMMENT='Historical system commands that are executed';
1330
1331 -- --------------------------------------------------------
1332
1333 --
1334 -- Table structure for table icinga_timeperiods
1335 --
1336
1337 CREATE TABLE IF NOT EXISTS icinga_timeperiods (
1338   timeperiod_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1339   instance_id bigint unsigned default 0,
1340   config_type smallint default 0,
1341   timeperiod_object_id bigint unsigned default 0,
1342   alias varchar(255) character set latin1  default '',
1343   config_hash varchar(64) DEFAULT NULL,
1344   PRIMARY KEY  (timeperiod_id),
1345   UNIQUE KEY instance_id (instance_id,config_type,timeperiod_object_id)
1346 ) ENGINE=InnoDB  COMMENT='Timeperiod definitions';
1347
1348 -- --------------------------------------------------------
1349
1350 --
1351 -- Table structure for table icinga_timeperiod_timeranges
1352 --
1353
1354 CREATE TABLE IF NOT EXISTS icinga_timeperiod_timeranges (
1355   timeperiod_timerange_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1356   instance_id bigint unsigned default 0,
1357   timeperiod_id bigint unsigned default 0,
1358   day smallint default 0,
1359   start_sec  int default 0,
1360   end_sec  int default 0,
1361   PRIMARY KEY  (timeperiod_timerange_id)
1362 ) ENGINE=InnoDB  COMMENT='Timeperiod definitions';
1363
1364
1365 -- --------------------------------------------------------
1366 -- Icinga 2 specific schema extensions
1367 -- --------------------------------------------------------
1368
1369 --
1370 -- Table structure for table icinga_endpoints
1371 --
1372
1373 CREATE TABLE IF NOT EXISTS icinga_endpoints (
1374   endpoint_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1375   instance_id bigint unsigned default 0,
1376   endpoint_object_id bigint(20) unsigned DEFAULT '0',
1377   zone_object_id bigint(20) unsigned DEFAULT '0',
1378   config_type smallint(6) DEFAULT '0',
1379   identity varchar(255) DEFAULT NULL,
1380   node varchar(255) DEFAULT NULL,
1381   config_hash varchar(64) DEFAULT NULL,
1382   PRIMARY KEY  (endpoint_id)
1383 ) ENGINE=InnoDB COMMENT='Endpoint configuration';
1384
1385 -- --------------------------------------------------------
1386
1387 --
1388 -- Table structure for table icinga_endpointstatus
1389 --
1390
1391 CREATE TABLE IF NOT EXISTS icinga_endpointstatus (
1392   endpointstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1393   instance_id bigint unsigned default 0,
1394   endpoint_object_id bigint(20) unsigned DEFAULT '0',
1395   zone_object_id bigint(20) unsigned DEFAULT '0',
1396   status_update_time timestamp NULL,
1397   identity varchar(255) DEFAULT NULL,
1398   node varchar(255) DEFAULT NULL,
1399   is_connected smallint(6),
1400   PRIMARY KEY  (endpointstatus_id)
1401 ) ENGINE=InnoDB COMMENT='Endpoint status';
1402
1403 --
1404 -- Table structure for table icinga_zones
1405 --
1406
1407 CREATE TABLE IF NOT EXISTS icinga_zones (
1408   zone_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1409   instance_id bigint unsigned default 0,
1410   zone_object_id bigint(20) unsigned DEFAULT '0',
1411   config_type smallint(6) DEFAULT '0',
1412   parent_zone_object_id bigint(20) unsigned DEFAULT '0',
1413   is_global smallint(6),
1414   config_hash varchar(64) DEFAULT NULL,
1415   PRIMARY KEY  (zone_id)
1416 ) ENGINE=InnoDB COMMENT='Zone configuration';
1417
1418 -- --------------------------------------------------------
1419
1420 --
1421 -- Table structure for table icinga_zonestatus
1422 --
1423
1424 CREATE TABLE IF NOT EXISTS icinga_zonestatus (
1425   zonestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1426   instance_id bigint unsigned default 0,
1427   zone_object_id bigint(20) unsigned DEFAULT '0',
1428   status_update_time timestamp NULL,
1429   parent_zone_object_id bigint(20) unsigned DEFAULT '0',
1430   PRIMARY KEY  (zonestatus_id)
1431 ) ENGINE=InnoDB COMMENT='Zone status';
1432
1433
1434
1435
1436 ALTER TABLE icinga_servicestatus ADD COLUMN endpoint_object_id bigint default NULL;
1437 ALTER TABLE icinga_hoststatus ADD COLUMN endpoint_object_id bigint default NULL;
1438 ALTER TABLE icinga_contactstatus ADD COLUMN endpoint_object_id bigint default NULL;
1439 ALTER TABLE icinga_programstatus ADD COLUMN endpoint_object_id bigint default NULL;
1440 ALTER TABLE icinga_comments ADD COLUMN endpoint_object_id bigint default NULL;
1441 ALTER TABLE icinga_scheduleddowntime ADD COLUMN endpoint_object_id bigint default NULL;
1442 ALTER TABLE icinga_runtimevariables ADD COLUMN endpoint_object_id bigint default NULL;
1443 ALTER TABLE icinga_customvariablestatus ADD COLUMN endpoint_object_id bigint default NULL;
1444
1445 ALTER TABLE icinga_acknowledgements ADD COLUMN endpoint_object_id bigint default NULL;
1446 ALTER TABLE icinga_commenthistory ADD COLUMN endpoint_object_id bigint default NULL;
1447 ALTER TABLE icinga_contactnotifications ADD COLUMN endpoint_object_id bigint default NULL;
1448 ALTER TABLE icinga_downtimehistory ADD COLUMN endpoint_object_id bigint default NULL;
1449 ALTER TABLE icinga_eventhandlers ADD COLUMN endpoint_object_id bigint default NULL;
1450 ALTER TABLE icinga_externalcommands ADD COLUMN endpoint_object_id bigint default NULL;
1451 ALTER TABLE icinga_flappinghistory ADD COLUMN endpoint_object_id bigint default NULL;
1452 ALTER TABLE icinga_hostchecks ADD COLUMN endpoint_object_id bigint default NULL;
1453 ALTER TABLE icinga_logentries ADD COLUMN endpoint_object_id bigint default NULL;
1454 ALTER TABLE icinga_notifications ADD COLUMN endpoint_object_id bigint default NULL;
1455 ALTER TABLE icinga_processevents ADD COLUMN endpoint_object_id bigint default NULL;
1456 ALTER TABLE icinga_servicechecks ADD COLUMN endpoint_object_id bigint default NULL;
1457 ALTER TABLE icinga_statehistory ADD COLUMN endpoint_object_id bigint default NULL;
1458 ALTER TABLE icinga_systemcommands ADD COLUMN endpoint_object_id bigint default NULL;
1459
1460 -- -----------------------------------------
1461 -- add index (delete)
1462 -- -----------------------------------------
1463
1464 -- for periodic delete
1465 -- instance_id and
1466 -- SYSTEMCOMMANDS, SERVICECHECKS, HOSTCHECKS, EVENTHANDLERS  => start_time
1467 -- EXTERNALCOMMANDS => entry_time
1468
1469 -- instance_id
1470 CREATE INDEX systemcommands_i_id_idx on icinga_systemcommands(instance_id);
1471 CREATE INDEX servicechecks_i_id_idx on icinga_servicechecks(instance_id);
1472 CREATE INDEX hostchecks_i_id_idx on icinga_hostchecks(instance_id);
1473 CREATE INDEX eventhandlers_i_id_idx on icinga_eventhandlers(instance_id);
1474 CREATE INDEX externalcommands_i_id_idx on icinga_externalcommands(instance_id);
1475
1476 -- time
1477 CREATE INDEX systemcommands_time_id_idx on icinga_systemcommands(start_time);
1478 CREATE INDEX servicechecks_time_id_idx on icinga_servicechecks(start_time);
1479 CREATE INDEX hostchecks_time_id_idx on icinga_hostchecks(start_time);
1480 CREATE INDEX eventhandlers_time_id_idx on icinga_eventhandlers(start_time);
1481 CREATE INDEX externalcommands_time_id_idx on icinga_externalcommands(entry_time);
1482
1483
1484 -- for starting cleanup - referenced in dbhandler.c:882
1485 -- instance_id only
1486
1487 -- realtime data
1488 CREATE INDEX programstatus_i_id_idx on icinga_programstatus(instance_id);
1489 CREATE INDEX hoststatus_i_id_idx on icinga_hoststatus(instance_id);
1490 CREATE INDEX servicestatus_i_id_idx on icinga_servicestatus(instance_id);
1491 CREATE INDEX contactstatus_i_id_idx on icinga_contactstatus(instance_id);
1492 CREATE INDEX comments_i_id_idx on icinga_comments(instance_id);
1493 CREATE INDEX scheduleddowntime_i_id_idx on icinga_scheduleddowntime(instance_id);
1494 CREATE INDEX runtimevariables_i_id_idx on icinga_runtimevariables(instance_id);
1495 CREATE INDEX customvariablestatus_i_id_idx on icinga_customvariablestatus(instance_id);
1496
1497 -- config data
1498 CREATE INDEX configfiles_i_id_idx on icinga_configfiles(instance_id);
1499 CREATE INDEX configfilevariables_i_id_idx on icinga_configfilevariables(instance_id);
1500 CREATE INDEX customvariables_i_id_idx on icinga_customvariables(instance_id);
1501 CREATE INDEX commands_i_id_idx on icinga_commands(instance_id);
1502 CREATE INDEX timeperiods_i_id_idx on icinga_timeperiods(instance_id);
1503 CREATE INDEX timeperiod_timeranges_i_id_idx on icinga_timeperiod_timeranges(instance_id);
1504 CREATE INDEX contactgroups_i_id_idx on icinga_contactgroups(instance_id);
1505 CREATE INDEX contactgroup_members_i_id_idx on icinga_contactgroup_members(instance_id);
1506 CREATE INDEX hostgroups_i_id_idx on icinga_hostgroups(instance_id);
1507 CREATE INDEX hostgroup_members_i_id_idx on icinga_hostgroup_members(instance_id);
1508 CREATE INDEX servicegroups_i_id_idx on icinga_servicegroups(instance_id);
1509 CREATE INDEX servicegroup_members_i_id_idx on icinga_servicegroup_members(instance_id);
1510 CREATE INDEX hostesc_i_id_idx on icinga_hostescalations(instance_id);
1511 CREATE INDEX hostesc_contacts_i_id_idx on icinga_hostescalation_contacts(instance_id);
1512 CREATE INDEX serviceesc_i_id_idx on icinga_serviceescalations(instance_id);
1513 CREATE INDEX serviceesc_contacts_i_id_idx on icinga_serviceescalation_contacts(instance_id);
1514 CREATE INDEX hostdependencies_i_id_idx on icinga_hostdependencies(instance_id);
1515 CREATE INDEX contacts_i_id_idx on icinga_contacts(instance_id);
1516 CREATE INDEX contact_addresses_i_id_idx on icinga_contact_addresses(instance_id);
1517 CREATE INDEX contact_notifcommands_i_id_idx on icinga_contact_notificationcommands(instance_id);
1518 CREATE INDEX hosts_i_id_idx on icinga_hosts(instance_id);
1519 CREATE INDEX host_parenthosts_i_id_idx on icinga_host_parenthosts(instance_id);
1520 CREATE INDEX host_contacts_i_id_idx on icinga_host_contacts(instance_id);
1521 CREATE INDEX services_i_id_idx on icinga_services(instance_id);
1522 CREATE INDEX service_contacts_i_id_idx on icinga_service_contacts(instance_id);
1523 CREATE INDEX service_contactgroups_i_id_idx on icinga_service_contactgroups(instance_id);
1524 CREATE INDEX host_contactgroups_i_id_idx on icinga_host_contactgroups(instance_id);
1525 CREATE INDEX hostesc_cgroups_i_id_idx on icinga_hostescalation_contactgroups(instance_id);
1526 CREATE INDEX serviceesc_cgroups_i_id_idx on icinga_serviceescalation_contactgroups(instance_id);
1527
1528 -- -----------------------------------------
1529 -- more index stuff (WHERE clauses)
1530 -- -----------------------------------------
1531
1532 -- hosts
1533 CREATE INDEX hosts_host_object_id_idx on icinga_hosts(host_object_id);
1534
1535 -- hoststatus
1536 CREATE INDEX hoststatus_stat_upd_time_idx on icinga_hoststatus(status_update_time);
1537 CREATE INDEX hoststatus_current_state_idx on icinga_hoststatus(current_state);
1538 CREATE INDEX hoststatus_check_type_idx on icinga_hoststatus(check_type);
1539 CREATE INDEX hoststatus_state_type_idx on icinga_hoststatus(state_type);
1540 CREATE INDEX hoststatus_last_state_chg_idx on icinga_hoststatus(last_state_change);
1541 CREATE INDEX hoststatus_notif_enabled_idx on icinga_hoststatus(notifications_enabled);
1542 CREATE INDEX hoststatus_problem_ack_idx on icinga_hoststatus(problem_has_been_acknowledged);
1543 CREATE INDEX hoststatus_act_chks_en_idx on icinga_hoststatus(active_checks_enabled);
1544 CREATE INDEX hoststatus_pas_chks_en_idx on icinga_hoststatus(passive_checks_enabled);
1545 CREATE INDEX hoststatus_event_hdl_en_idx on icinga_hoststatus(event_handler_enabled);
1546 CREATE INDEX hoststatus_flap_det_en_idx on icinga_hoststatus(flap_detection_enabled);
1547 CREATE INDEX hoststatus_is_flapping_idx on icinga_hoststatus(is_flapping);
1548 CREATE INDEX hoststatus_p_state_chg_idx on icinga_hoststatus(percent_state_change);
1549 CREATE INDEX hoststatus_latency_idx on icinga_hoststatus(latency);
1550 CREATE INDEX hoststatus_ex_time_idx on icinga_hoststatus(execution_time);
1551 CREATE INDEX hoststatus_sch_downt_d_idx on icinga_hoststatus(scheduled_downtime_depth);
1552
1553 -- services
1554 CREATE INDEX services_host_object_id_idx on icinga_services(host_object_id);
1555
1556 -- servicestatus
1557 CREATE INDEX srvcstatus_stat_upd_time_idx on icinga_servicestatus(status_update_time);
1558 CREATE INDEX srvcstatus_current_state_idx on icinga_servicestatus(current_state);
1559 CREATE INDEX srvcstatus_check_type_idx on icinga_servicestatus(check_type);
1560 CREATE INDEX srvcstatus_state_type_idx on icinga_servicestatus(state_type);
1561 CREATE INDEX srvcstatus_last_state_chg_idx on icinga_servicestatus(last_state_change);
1562 CREATE INDEX srvcstatus_notif_enabled_idx on icinga_servicestatus(notifications_enabled);
1563 CREATE INDEX srvcstatus_problem_ack_idx on icinga_servicestatus(problem_has_been_acknowledged);
1564 CREATE INDEX srvcstatus_act_chks_en_idx on icinga_servicestatus(active_checks_enabled);
1565 CREATE INDEX srvcstatus_pas_chks_en_idx on icinga_servicestatus(passive_checks_enabled);
1566 CREATE INDEX srvcstatus_event_hdl_en_idx on icinga_servicestatus(event_handler_enabled);
1567 CREATE INDEX srvcstatus_flap_det_en_idx on icinga_servicestatus(flap_detection_enabled);
1568 CREATE INDEX srvcstatus_is_flapping_idx on icinga_servicestatus(is_flapping);
1569 CREATE INDEX srvcstatus_p_state_chg_idx on icinga_servicestatus(percent_state_change);
1570 CREATE INDEX srvcstatus_latency_idx on icinga_servicestatus(latency);
1571 CREATE INDEX srvcstatus_ex_time_idx on icinga_servicestatus(execution_time);
1572 CREATE INDEX srvcstatus_sch_downt_d_idx on icinga_servicestatus(scheduled_downtime_depth);
1573
1574 -- hostchecks
1575 CREATE INDEX hostchks_h_obj_id_idx on icinga_hostchecks(host_object_id);
1576
1577 -- servicechecks
1578 CREATE INDEX servicechks_s_obj_id_idx on icinga_servicechecks(service_object_id);
1579
1580 -- objects
1581 CREATE INDEX objects_objtype_id_idx ON icinga_objects(objecttype_id);
1582 CREATE INDEX objects_name1_idx ON icinga_objects(name1);
1583 CREATE INDEX objects_name2_idx ON icinga_objects(name2);
1584 CREATE INDEX objects_inst_id_idx ON icinga_objects(instance_id);
1585
1586 -- instances
1587 -- CREATE INDEX instances_name_idx on icinga_instances(instance_name);
1588
1589 -- logentries
1590 -- CREATE INDEX loge_instance_id_idx on icinga_logentries(instance_id);
1591 -- #236
1592 CREATE INDEX loge_time_idx on icinga_logentries(logentry_time);
1593 -- CREATE INDEX loge_data_idx on icinga_logentries(logentry_data);
1594 CREATE INDEX loge_inst_id_time_idx on icinga_logentries (instance_id ASC, logentry_time DESC);
1595
1596 -- commenthistory
1597 -- CREATE INDEX c_hist_instance_id_idx on icinga_logentries(instance_id);
1598 -- CREATE INDEX c_hist_c_time_idx on icinga_logentries(comment_time);
1599 -- CREATE INDEX c_hist_i_c_id_idx on icinga_logentries(internal_comment_id);
1600
1601 -- downtimehistory
1602 -- CREATE INDEX d_t_hist_nstance_id_idx on icinga_downtimehistory(instance_id);
1603 -- CREATE INDEX d_t_hist_type_idx on icinga_downtimehistory(downtime_type);
1604 -- CREATE INDEX d_t_hist_object_id_idx on icinga_downtimehistory(object_id);
1605 -- CREATE INDEX d_t_hist_entry_time_idx on icinga_downtimehistory(entry_time);
1606 -- CREATE INDEX d_t_hist_sched_start_idx on icinga_downtimehistory(scheduled_start_time);
1607 -- CREATE INDEX d_t_hist_sched_end_idx on icinga_downtimehistory(scheduled_end_time);
1608
1609 -- scheduleddowntime
1610 -- CREATE INDEX sched_d_t_downtime_type_idx on icinga_scheduleddowntime(downtime_type);
1611 -- CREATE INDEX sched_d_t_object_id_idx on icinga_scheduleddowntime(object_id);
1612 -- CREATE INDEX sched_d_t_entry_time_idx on icinga_scheduleddowntime(entry_time);
1613 -- CREATE INDEX sched_d_t_start_time_idx on icinga_scheduleddowntime(scheduled_start_time);
1614 -- CREATE INDEX sched_d_t_end_time_idx on icinga_scheduleddowntime(scheduled_end_time);
1615
1616 -- statehistory
1617 CREATE INDEX statehist_i_id_o_id_s_ty_s_ti on icinga_statehistory(instance_id, object_id, state_type, state_time);
1618 -- #2274
1619 create index statehist_state_idx on icinga_statehistory(object_id,state);
1620
1621
1622 -- Icinga Web Notifications
1623 CREATE INDEX notification_idx ON icinga_notifications(notification_type, object_id, start_time);
1624 CREATE INDEX notification_object_id_idx ON icinga_notifications(object_id);
1625 CREATE INDEX contact_notification_idx ON icinga_contactnotifications(notification_id, contact_object_id);
1626 CREATE INDEX contacts_object_id_idx ON icinga_contacts(contact_object_id);
1627 CREATE INDEX contact_notif_meth_notif_idx ON icinga_contactnotificationmethods(contactnotification_id, command_object_id);
1628 CREATE INDEX command_object_idx ON icinga_commands(object_id);
1629 CREATE INDEX services_combined_object_idx ON icinga_services(service_object_id, host_object_id);
1630
1631
1632 -- #2618
1633 CREATE INDEX cntgrpmbrs_cgid_coid ON icinga_contactgroup_members (contactgroup_id,contact_object_id);
1634 CREATE INDEX hstgrpmbrs_hgid_hoid ON icinga_hostgroup_members (hostgroup_id,host_object_id);
1635 CREATE INDEX hstcntgrps_hid_cgoid ON icinga_host_contactgroups (host_id,contactgroup_object_id);
1636 CREATE INDEX hstprnthsts_hid_phoid ON icinga_host_parenthosts (host_id,parent_host_object_id);
1637 CREATE INDEX runtimevars_iid_varn ON icinga_runtimevariables (instance_id,varname);
1638 CREATE INDEX sgmbrs_sgid_soid ON icinga_servicegroup_members (servicegroup_id,service_object_id);
1639 CREATE INDEX scgrps_sid_cgoid ON icinga_service_contactgroups (service_id,contactgroup_object_id);
1640 CREATE INDEX tperiod_tid_d_ss_es ON icinga_timeperiod_timeranges (timeperiod_id,day,start_sec,end_sec);
1641
1642 -- #3649
1643 CREATE INDEX sla_idx_sthist ON icinga_statehistory (object_id, state_time DESC);
1644 CREATE INDEX sla_idx_dohist ON icinga_downtimehistory (object_id, actual_start_time, actual_end_time);
1645 CREATE INDEX sla_idx_obj ON icinga_objects (objecttype_id, is_active, name1);
1646
1647 -- #4985
1648 CREATE INDEX commenthistory_delete_idx ON icinga_commenthistory (instance_id, comment_time, internal_comment_id);
1649
1650 -- #10070
1651 CREATE INDEX idx_comments_object_id on icinga_comments(object_id);
1652 CREATE INDEX idx_scheduleddowntime_object_id on icinga_scheduleddowntime(object_id);
1653
1654 -- #10066
1655 CREATE INDEX idx_endpoints_object_id on icinga_endpoints(endpoint_object_id);
1656 CREATE INDEX idx_endpointstatus_object_id on icinga_endpointstatus(endpoint_object_id);
1657
1658 CREATE INDEX idx_endpoints_zone_object_id on icinga_endpoints(zone_object_id);
1659 CREATE INDEX idx_endpointstatus_zone_object_id on icinga_endpointstatus(zone_object_id);
1660
1661 CREATE INDEX idx_zones_object_id on icinga_zones(zone_object_id);
1662 CREATE INDEX idx_zonestatus_object_id on icinga_zonestatus(zone_object_id);
1663
1664 CREATE INDEX idx_zones_parent_object_id on icinga_zones(parent_zone_object_id);
1665 CREATE INDEX idx_zonestatus_parent_object_id on icinga_zonestatus(parent_zone_object_id);
1666
1667 -- #12210
1668 CREATE INDEX idx_comments_session_del ON icinga_comments (instance_id, session_token);
1669 CREATE INDEX idx_downtimes_session_del ON icinga_scheduleddowntime (instance_id, session_token);
1670
1671 -- #12107
1672 CREATE INDEX idx_statehistory_cleanup on icinga_statehistory(instance_id, state_time);
1673
1674 -- #12435
1675 CREATE INDEX idx_customvariables_object_id on icinga_customvariables(object_id);
1676 CREATE INDEX idx_contactgroup_members_object_id on icinga_contactgroup_members(contact_object_id);
1677 CREATE INDEX idx_hostgroup_members_object_id on icinga_hostgroup_members(host_object_id);
1678 CREATE INDEX idx_servicegroup_members_object_id on icinga_servicegroup_members(service_object_id);
1679 CREATE INDEX idx_servicedependencies_dependent_service_object_id on icinga_servicedependencies(dependent_service_object_id);
1680 CREATE INDEX idx_hostdependencies_dependent_host_object_id on icinga_hostdependencies(dependent_host_object_id);
1681 CREATE INDEX idx_service_contacts_service_id on icinga_service_contacts(service_id);
1682 CREATE INDEX idx_host_contacts_host_id on icinga_host_contacts(host_id);
1683
1684 -- #5458
1685 CREATE INDEX idx_downtimehistory_remove ON icinga_downtimehistory (object_id, entry_time, scheduled_start_time, scheduled_end_time);
1686 CREATE INDEX idx_scheduleddowntime_remove ON icinga_scheduleddowntime (object_id, entry_time, scheduled_start_time, scheduled_end_time);
1687
1688
1689 -- -----------------------------------------
1690 -- set dbversion
1691 -- -----------------------------------------
1692 INSERT INTO icinga_dbversion (name, version, create_time, modify_time) VALUES ('idoutils', '1.14.3', NOW(), NOW())
1693 ON DUPLICATE KEY UPDATE version='1.14.3', modify_time=NOW();
1694
1695