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