]> granicus.if.org Git - icinga2/blob - lib/db_ido_mysql/schema/mysql.sql
Update copyright headers for 2016
[icinga2] / lib / db_ido_mysql / schema / mysql.sql
1 -- --------------------------------------------------------
2 -- mysql.sql
3 -- DB definition for IDO MySQL
4 --
5 -- Copyright (c) 2009-2016 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   name TEXT character set latin1 default NULL,
86   PRIMARY KEY  (commenthistory_id),
87   UNIQUE KEY instance_id (instance_id,object_id,comment_time,internal_comment_id)
88 ) ENGINE=InnoDB  COMMENT='Historical host and service comments';
89
90 -- --------------------------------------------------------
91
92 --
93 -- Table structure for table icinga_comments
94 --
95
96 CREATE TABLE IF NOT EXISTS icinga_comments (
97   comment_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
98   instance_id bigint unsigned default 0,
99   entry_time timestamp  default '0000-00-00 00:00:00',
100   entry_time_usec  int default 0,
101   comment_type smallint default 0,
102   entry_type smallint default 0,
103   object_id bigint unsigned default 0,
104   comment_time timestamp  default '0000-00-00 00:00:00',
105   internal_comment_id bigint unsigned default 0,
106   author_name varchar(64) character set latin1  default '',
107   comment_data TEXT character set latin1  default '',
108   is_persistent smallint default 0,
109   comment_source smallint default 0,
110   expires smallint default 0,
111   expiration_time timestamp  default '0000-00-00 00:00:00',
112   name TEXT character set latin1 default NULL,
113   PRIMARY KEY  (comment_id),
114   UNIQUE KEY instance_id (instance_id,object_id,comment_time,internal_comment_id)
115 ) ENGINE=InnoDB  COMMENT='Usercomments on Icinga objects';
116
117 -- --------------------------------------------------------
118
119 --
120 -- Table structure for table icinga_configfiles
121 --
122
123 CREATE TABLE IF NOT EXISTS icinga_configfiles (
124   configfile_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
125   instance_id bigint unsigned default 0,
126   configfile_type smallint default 0,
127   configfile_path varchar(255) character set latin1  default '',
128   PRIMARY KEY  (configfile_id),
129   UNIQUE KEY instance_id (instance_id,configfile_type,configfile_path)
130 ) ENGINE=InnoDB  COMMENT='Configuration files';
131
132 -- --------------------------------------------------------
133
134 --
135 -- Table structure for table icinga_configfilevariables
136 --
137
138 CREATE TABLE IF NOT EXISTS icinga_configfilevariables (
139   configfilevariable_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
140   instance_id bigint unsigned default 0,
141   configfile_id bigint unsigned default 0,
142   varname varchar(64) character set latin1  default '',
143   varvalue TEXT character set latin1  default '',
144   PRIMARY KEY  (configfilevariable_id)
145 ) ENGINE=InnoDB  COMMENT='Configuration file variables';
146
147 -- --------------------------------------------------------
148
149 --
150 -- Table structure for table icinga_conninfo
151 --
152
153 CREATE TABLE IF NOT EXISTS icinga_conninfo (
154   conninfo_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
155   instance_id bigint unsigned default 0,
156   agent_name varchar(32) character set latin1  default '',
157   agent_version varchar(32) character set latin1  default '',
158   disposition varchar(32) character set latin1  default '',
159   connect_source varchar(32) character set latin1  default '',
160   connect_type varchar(32) character set latin1  default '',
161   connect_time timestamp  default '0000-00-00 00:00:00',
162   disconnect_time timestamp  default '0000-00-00 00:00:00',
163   last_checkin_time timestamp  default '0000-00-00 00:00:00',
164   data_start_time timestamp  default '0000-00-00 00:00:00',
165   data_end_time timestamp  default '0000-00-00 00:00:00',
166   bytes_processed bigint unsigned  default '0',
167   lines_processed bigint unsigned  default '0',
168   entries_processed bigint unsigned  default '0',
169   PRIMARY KEY  (conninfo_id)
170 ) ENGINE=InnoDB  COMMENT='IDO2DB daemon connection information';
171
172 -- --------------------------------------------------------
173
174 --
175 -- Table structure for table icinga_contactgroups
176 --
177
178 CREATE TABLE IF NOT EXISTS icinga_contactgroups (
179   contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
180   instance_id bigint unsigned default 0,
181   config_type smallint default 0,
182   contactgroup_object_id bigint unsigned default 0,
183   alias TEXT character set latin1  default '',
184   PRIMARY KEY  (contactgroup_id),
185   UNIQUE KEY instance_id (instance_id,config_type,contactgroup_object_id)
186 ) ENGINE=InnoDB  COMMENT='Contactgroup definitions';
187
188 -- --------------------------------------------------------
189
190 --
191 -- Table structure for table icinga_contactgroup_members
192 --
193
194 CREATE TABLE IF NOT EXISTS icinga_contactgroup_members (
195   contactgroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
196   instance_id bigint unsigned default 0,
197   contactgroup_id bigint unsigned default 0,
198   contact_object_id bigint unsigned default 0,
199   PRIMARY KEY  (contactgroup_member_id)
200 ) ENGINE=InnoDB  COMMENT='Contactgroup members';
201
202 -- --------------------------------------------------------
203
204 --
205 -- Table structure for table icinga_contactnotificationmethods
206 --
207
208 CREATE TABLE IF NOT EXISTS icinga_contactnotificationmethods (
209   contactnotificationmethod_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
210   instance_id bigint unsigned default 0,
211   contactnotification_id bigint unsigned default 0,
212   start_time timestamp  default '0000-00-00 00:00:00',
213   start_time_usec  int default 0,
214   end_time timestamp  default '0000-00-00 00:00:00',
215   end_time_usec  int default 0,
216   command_object_id bigint unsigned default 0,
217   command_args TEXT character set latin1  default '',
218   PRIMARY KEY  (contactnotificationmethod_id),
219   UNIQUE KEY instance_id (instance_id,contactnotification_id,start_time,start_time_usec)
220 ) ENGINE=InnoDB  COMMENT='Historical record of contact notification methods';
221
222 -- --------------------------------------------------------
223
224 --
225 -- Table structure for table icinga_contactnotifications
226 --
227
228 CREATE TABLE IF NOT EXISTS icinga_contactnotifications (
229   contactnotification_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
230   instance_id bigint unsigned default 0,
231   notification_id bigint unsigned default 0,
232   contact_object_id bigint unsigned default 0,
233   start_time timestamp  default '0000-00-00 00:00:00',
234   start_time_usec  int default 0,
235   end_time timestamp  default '0000-00-00 00:00:00',
236   end_time_usec  int default 0,
237   PRIMARY KEY  (contactnotification_id),
238   UNIQUE KEY instance_id (instance_id,contact_object_id,start_time,start_time_usec)
239 ) ENGINE=InnoDB  COMMENT='Historical record of contact notifications';
240
241 -- --------------------------------------------------------
242
243 --
244 -- Table structure for table icinga_contacts
245 --
246
247 CREATE TABLE IF NOT EXISTS icinga_contacts (
248   contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
249   instance_id bigint unsigned default 0,
250   config_type smallint default 0,
251   contact_object_id bigint unsigned default 0,
252   alias TEXT character set latin1  default '',
253   email_address varchar(255) character set latin1  default '',
254   pager_address varchar(64) character set latin1  default '',
255   host_timeperiod_object_id bigint unsigned default 0,
256   service_timeperiod_object_id bigint unsigned default 0,
257   host_notifications_enabled smallint default 0,
258   service_notifications_enabled smallint default 0,
259   can_submit_commands smallint default 0,
260   notify_service_recovery smallint default 0,
261   notify_service_warning smallint default 0,
262   notify_service_unknown smallint default 0,
263   notify_service_critical smallint default 0,
264   notify_service_flapping smallint default 0,
265   notify_service_downtime smallint default 0,
266   notify_host_recovery smallint default 0,
267   notify_host_down smallint default 0,
268   notify_host_unreachable smallint default 0,
269   notify_host_flapping smallint default 0,
270   notify_host_downtime smallint default 0,
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  default '0000-00-00 00:00:00',
286   host_notifications_enabled smallint default 0,
287   service_notifications_enabled smallint default 0,
288   last_host_notification timestamp  default '0000-00-00 00:00:00',
289   last_service_notification timestamp  default '0000-00-00 00:00:00',
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  default '',
344   is_json smallint default 0,
345   session_token int default NULL,
346   PRIMARY KEY  (customvariable_id),
347   UNIQUE KEY object_id_2 (object_id,config_type,varname),
348   KEY varname (varname)
349 ) ENGINE=InnoDB COMMENT='Custom variables';
350
351 -- --------------------------------------------------------
352
353 --
354 -- Table structure for table icinga_customvariablestatus
355 --
356
357 CREATE TABLE IF NOT EXISTS icinga_customvariablestatus (
358   customvariablestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
359   instance_id bigint unsigned default 0,
360   object_id bigint unsigned default 0,
361   status_update_time timestamp  default '0000-00-00 00:00:00',
362   has_been_modified smallint default 0,
363   varname varchar(255) character set latin1 collate latin1_general_cs default NULL,
364   varvalue TEXT character set latin1  default '',
365   is_json smallint default 0,
366   session_token int default NULL,
367   PRIMARY KEY  (customvariablestatus_id),
368   UNIQUE KEY object_id_2 (object_id,varname),
369   KEY varname (varname)
370 ) ENGINE=InnoDB COMMENT='Custom variable status information';
371
372 -- --------------------------------------------------------
373
374 --
375 -- Table structure for table icinga_dbversion
376 --
377
378 CREATE TABLE IF NOT EXISTS icinga_dbversion (
379   dbversion_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
380   name varchar(10) character set latin1  default '',
381   version varchar(10) character set latin1  default '',
382   create_time timestamp default '0000-00-00 00:00:00',
383   modify_time timestamp default '0000-00-00 00:00:00',
384   PRIMARY KEY (dbversion_id),
385   UNIQUE KEY dbversion (name)
386 ) ENGINE=InnoDB;
387
388 -- --------------------------------------------------------
389
390 --
391 -- Table structure for table icinga_downtimehistory
392 --
393
394 CREATE TABLE IF NOT EXISTS icinga_downtimehistory (
395   downtimehistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
396   instance_id bigint unsigned default 0,
397   downtime_type smallint default 0,
398   object_id bigint unsigned default 0,
399   entry_time timestamp  default '0000-00-00 00:00:00',
400   author_name varchar(64) character set latin1  default '',
401   comment_data TEXT character set latin1  default '',
402   internal_downtime_id bigint unsigned default 0,
403   triggered_by_id bigint unsigned default 0,
404   is_fixed smallint default 0,
405   duration bigint(20) default 0,
406   scheduled_start_time timestamp  default '0000-00-00 00:00:00',
407   scheduled_end_time timestamp  default '0000-00-00 00:00:00',
408   was_started smallint default 0,
409   actual_start_time timestamp  default '0000-00-00 00:00:00',
410   actual_start_time_usec  int default 0,
411   actual_end_time timestamp  default '0000-00-00 00:00:00',
412   actual_end_time_usec  int default 0,
413   was_cancelled smallint default 0,
414   is_in_effect smallint default 0,
415   trigger_time timestamp  default '0000-00-00 00:00:00',
416   name TEXT character set latin1 default NULL,
417   PRIMARY KEY  (downtimehistory_id),
418   UNIQUE KEY instance_id (instance_id,object_id,entry_time,internal_downtime_id)
419 ) ENGINE=InnoDB  COMMENT='Historical scheduled host and service downtime';
420
421 -- --------------------------------------------------------
422
423 --
424 -- Table structure for table icinga_eventhandlers
425 --
426
427 CREATE TABLE IF NOT EXISTS icinga_eventhandlers (
428   eventhandler_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
429   instance_id bigint unsigned default 0,
430   eventhandler_type smallint default 0,
431   object_id bigint unsigned default 0,
432   state smallint default 0,
433   state_type smallint default 0,
434   start_time timestamp  default '0000-00-00 00:00:00',
435   start_time_usec  int default 0,
436   end_time timestamp  default '0000-00-00 00:00:00',
437   end_time_usec  int default 0,
438   command_object_id bigint unsigned default 0,
439   command_args TEXT character set latin1  default '',
440   command_line TEXT character set latin1  default '',
441   timeout smallint default 0,
442   early_timeout smallint default 0,
443   execution_time double  default '0',
444   return_code smallint default 0,
445   output TEXT character set latin1  default '',
446   long_output TEXT  default '',
447   PRIMARY KEY  (eventhandler_id),
448   UNIQUE KEY instance_id (instance_id,object_id,start_time,start_time_usec)
449 ) ENGINE=InnoDB COMMENT='Historical host and service event handlers';
450
451 -- --------------------------------------------------------
452
453 --
454 -- Table structure for table icinga_externalcommands
455 --
456
457 CREATE TABLE IF NOT EXISTS icinga_externalcommands (
458   externalcommand_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
459   instance_id bigint unsigned default 0,
460   entry_time timestamp  default '0000-00-00 00:00:00',
461   command_type smallint default 0,
462   command_name varchar(128) character set latin1  default '',
463   command_args TEXT character set latin1  default '',
464   PRIMARY KEY  (externalcommand_id)
465 ) ENGINE=InnoDB  COMMENT='Historical record of processed external commands';
466
467 -- --------------------------------------------------------
468
469 --
470 -- Table structure for table icinga_flappinghistory
471 --
472
473 CREATE TABLE IF NOT EXISTS icinga_flappinghistory (
474   flappinghistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
475   instance_id bigint unsigned default 0,
476   event_time timestamp  default '0000-00-00 00:00:00',
477   event_time_usec  int default 0,
478   event_type smallint default 0,
479   reason_type smallint default 0,
480   flapping_type smallint default 0,
481   object_id bigint unsigned default 0,
482   percent_state_change double  default '0',
483   low_threshold double  default '0',
484   high_threshold double  default '0',
485   comment_time timestamp  default '0000-00-00 00:00:00',
486   internal_comment_id bigint unsigned default 0,
487   PRIMARY KEY  (flappinghistory_id)
488 ) ENGINE=InnoDB  COMMENT='Current and historical record of host and service flapping';
489
490 -- --------------------------------------------------------
491
492 --
493 -- Table structure for table icinga_hostchecks
494 --
495
496 CREATE TABLE IF NOT EXISTS icinga_hostchecks (
497   hostcheck_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
498   instance_id bigint unsigned default 0,
499   host_object_id bigint unsigned default 0,
500   check_type smallint default 0,
501   is_raw_check smallint default 0,
502   current_check_attempt smallint default 0,
503   max_check_attempts smallint default 0,
504   state smallint default 0,
505   state_type smallint default 0,
506   start_time timestamp  default '0000-00-00 00:00:00',
507   start_time_usec  int default 0,
508   end_time timestamp  default '0000-00-00 00:00:00',
509   end_time_usec  int default 0,
510   command_object_id bigint unsigned default 0,
511   command_args TEXT character set latin1  default '',
512   command_line TEXT character set latin1  default '',
513   timeout smallint default 0,
514   early_timeout smallint default 0,
515   execution_time double  default '0',
516   latency double  default '0',
517   return_code smallint default 0,
518   output TEXT character set latin1  default '',
519   long_output TEXT  default '',
520   perfdata TEXT character set latin1  default '',
521   PRIMARY KEY  (hostcheck_id)
522 ) ENGINE=InnoDB  COMMENT='Historical host checks';
523
524 -- --------------------------------------------------------
525
526 --
527 -- Table structure for table icinga_hostdependencies
528 --
529
530 CREATE TABLE IF NOT EXISTS icinga_hostdependencies (
531   hostdependency_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
532   instance_id bigint unsigned default 0,
533   config_type smallint default 0,
534   host_object_id bigint unsigned default 0,
535   dependent_host_object_id bigint unsigned default 0,
536   dependency_type smallint default 0,
537   inherits_parent smallint default 0,
538   timeperiod_object_id bigint unsigned default 0,
539   fail_on_up smallint default 0,
540   fail_on_down smallint default 0,
541   fail_on_unreachable smallint default 0,
542   PRIMARY KEY  (hostdependency_id),
543   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)
544 ) ENGINE=InnoDB COMMENT='Host dependency definitions';
545
546 -- --------------------------------------------------------
547
548 --
549 -- Table structure for table icinga_hostescalations
550 --
551
552 CREATE TABLE IF NOT EXISTS icinga_hostescalations (
553   hostescalation_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
554   instance_id bigint unsigned default 0,
555   config_type smallint default 0,
556   host_object_id bigint unsigned default 0,
557   timeperiod_object_id bigint unsigned default 0,
558   first_notification smallint default 0,
559   last_notification smallint default 0,
560   notification_interval double  default '0',
561   escalate_on_recovery smallint default 0,
562   escalate_on_down smallint default 0,
563   escalate_on_unreachable smallint default 0,
564   PRIMARY KEY  (hostescalation_id),
565   UNIQUE KEY instance_id (instance_id,config_type,host_object_id,timeperiod_object_id,first_notification,last_notification)
566 ) ENGINE=InnoDB  COMMENT='Host escalation definitions';
567
568 -- --------------------------------------------------------
569
570 --
571 -- Table structure for table icinga_hostescalation_contactgroups
572 --
573
574 CREATE TABLE IF NOT EXISTS icinga_hostescalation_contactgroups (
575   hostescalation_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
576   instance_id bigint unsigned default 0,
577   hostescalation_id bigint unsigned default 0,
578   contactgroup_object_id bigint unsigned default 0,
579   PRIMARY KEY  (hostescalation_contactgroup_id),
580   UNIQUE KEY instance_id (hostescalation_id,contactgroup_object_id)
581 ) ENGINE=InnoDB  COMMENT='Host escalation contact groups';
582
583 -- --------------------------------------------------------
584
585 --
586 -- Table structure for table icinga_hostescalation_contacts
587 --
588
589 CREATE TABLE IF NOT EXISTS icinga_hostescalation_contacts (
590   hostescalation_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
591   instance_id bigint unsigned default 0,
592   hostescalation_id bigint unsigned default 0,
593   contact_object_id bigint unsigned default 0,
594   PRIMARY KEY  (hostescalation_contact_id),
595   UNIQUE KEY instance_id (instance_id,hostescalation_id,contact_object_id)
596 ) ENGINE=InnoDB  COMMENT='Host escalation contacts';
597
598 -- --------------------------------------------------------
599
600 --
601 -- Table structure for table icinga_hostgroups
602 --
603
604 CREATE TABLE IF NOT EXISTS icinga_hostgroups (
605   hostgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
606   instance_id bigint unsigned default 0,
607   config_type smallint default 0,
608   hostgroup_object_id bigint unsigned default 0,
609   alias TEXT character set latin1  default '',
610   notes TEXT character set latin1  default NULL,
611   notes_url TEXT character set latin1  default NULL,
612   action_url TEXT character set latin1  default NULL,
613   PRIMARY KEY  (hostgroup_id),
614   UNIQUE KEY instance_id (instance_id,hostgroup_object_id)
615 ) ENGINE=InnoDB  COMMENT='Hostgroup definitions';
616
617 -- --------------------------------------------------------
618
619 --
620 -- Table structure for table icinga_hostgroup_members
621 --
622
623 CREATE TABLE IF NOT EXISTS icinga_hostgroup_members (
624   hostgroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
625   instance_id bigint unsigned default 0,
626   hostgroup_id bigint unsigned default 0,
627   host_object_id bigint unsigned default 0,
628   PRIMARY KEY  (hostgroup_member_id)
629 ) ENGINE=InnoDB  COMMENT='Hostgroup members';
630
631 -- --------------------------------------------------------
632
633 --
634 -- Table structure for table icinga_hosts
635 --
636
637 CREATE TABLE IF NOT EXISTS icinga_hosts (
638   host_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
639   instance_id bigint unsigned default 0,
640   config_type smallint default 0,
641   host_object_id bigint unsigned default 0,
642   alias TEXT character set latin1  default '',
643   display_name varchar(255) character set latin1 collate latin1_general_cs  default '',
644   address varchar(128) character set latin1  default '',
645   address6 varchar(128) character set latin1  default '',
646   check_command_object_id bigint unsigned default 0,
647   check_command_args TEXT character set latin1  default '',
648   eventhandler_command_object_id bigint unsigned default 0,
649   eventhandler_command_args TEXT character set latin1  default '',
650   notification_timeperiod_object_id bigint unsigned default 0,
651   check_timeperiod_object_id bigint unsigned default 0,
652   failure_prediction_options varchar(128) character set latin1  default '',
653   check_interval double  default '0',
654   retry_interval double  default '0',
655   max_check_attempts smallint default 0,
656   first_notification_delay double  default '0',
657   notification_interval double  default '0',
658   notify_on_down smallint default 0,
659   notify_on_unreachable smallint default 0,
660   notify_on_recovery smallint default 0,
661   notify_on_flapping smallint default 0,
662   notify_on_downtime smallint default 0,
663   stalk_on_up smallint default 0,
664   stalk_on_down smallint default 0,
665   stalk_on_unreachable smallint default 0,
666   flap_detection_enabled smallint default 0,
667   flap_detection_on_up smallint default 0,
668   flap_detection_on_down smallint default 0,
669   flap_detection_on_unreachable smallint default 0,
670   low_flap_threshold double  default '0',
671   high_flap_threshold double  default '0',
672   process_performance_data smallint default 0,
673   freshness_checks_enabled smallint default 0,
674   freshness_threshold int default 0,
675   passive_checks_enabled smallint default 0,
676   event_handler_enabled smallint default 0,
677   active_checks_enabled smallint default 0,
678   retain_status_information smallint default 0,
679   retain_nonstatus_information smallint default 0,
680   notifications_enabled smallint default 0,
681   obsess_over_host smallint default 0,
682   failure_prediction_enabled smallint default 0,
683   notes TEXT character set latin1  default '',
684   notes_url TEXT character set latin1  default '',
685   action_url TEXT character set latin1  default '',
686   icon_image TEXT character set latin1  default '',
687   icon_image_alt TEXT character set latin1  default '',
688   vrml_image TEXT character set latin1  default '',
689   statusmap_image TEXT character set latin1  default '',
690   have_2d_coords smallint default 0,
691   x_2d smallint default 0,
692   y_2d smallint default 0,
693   have_3d_coords smallint default 0,
694   x_3d double  default '0',
695   y_3d double  default '0',
696   z_3d double  default '0',
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  default '0000-00-00 00:00:00',
713   output TEXT character set latin1  default '',
714   long_output TEXT  default '',
715   perfdata TEXT character set latin1  default '',
716   check_source TEXT 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  default '0000-00-00 00:00:00',
723   next_check timestamp  default '0000-00-00 00:00:00',
724   check_type smallint default 0,
725   last_state_change timestamp  default '0000-00-00 00:00:00',
726   last_hard_state_change timestamp  default '0000-00-00 00:00:00',
727   last_hard_state smallint default 0,
728   last_time_up timestamp  default '0000-00-00 00:00:00',
729   last_time_down timestamp  default '0000-00-00 00:00:00',
730   last_time_unreachable timestamp  default '0000-00-00 00:00:00',
731   state_type smallint default 0,
732   last_notification timestamp  default '0000-00-00 00:00:00',
733   next_notification timestamp  default '0000-00-00 00:00:00',
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 smallint 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  default '',
754   check_command TEXT character set latin1  default '',
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  default '0000-00-00 00:00:00',
828   entry_time timestamp  default '0000-00-00 00:00:00',
829   entry_time_usec  int default 0,
830   logentry_type  int default 0,
831   logentry_data TEXT character set latin1  default '',
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  default '0000-00-00 00:00:00',
851   start_time_usec  int default 0,
852   end_time timestamp  default '0000-00-00 00:00:00',
853   end_time_usec  int default 0,
854   state smallint default 0,
855   output TEXT character set latin1  default '',
856   long_output TEXT  default '',
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  default '0000-00-00 00:00:00',
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  default '0000-00-00 00:00:00',
910   program_start_time timestamp  default '0000-00-00 00:00:00',
911   program_end_time timestamp  default '0000-00-00 00:00:00',
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  default '0000-00-00 00:00:00',
917   last_log_rotation timestamp  default '0000-00-00 00:00:00',
918   notifications_enabled smallint default 0,
919   disable_notif_expire_time timestamp default '0000-00-00 00:00:00',
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  default '',
933   global_service_event_handler TEXT character set latin1  default '',
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  default '',
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  default '0000-00-00 00:00:00',
965   author_name varchar(64) character set latin1  default '',
966   comment_data TEXT character set latin1  default '',
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  default '0000-00-00 00:00:00',
972   scheduled_end_time timestamp  default '0000-00-00 00:00:00',
973   was_started smallint default 0,
974   actual_start_time timestamp  default '0000-00-00 00:00:00',
975   actual_start_time_usec  int default 0,
976   is_in_effect smallint default 0,
977   trigger_time timestamp  default '0000-00-00 00:00:00',
978   name TEXT character set latin1 default NULL,
979   PRIMARY KEY  (scheduleddowntime_id),
980   UNIQUE KEY instance_id (instance_id,object_id,entry_time,internal_downtime_id)
981 ) ENGINE=InnoDB COMMENT='Current scheduled host and service downtime';
982
983 -- --------------------------------------------------------
984
985 --
986 -- Table structure for table icinga_servicechecks
987 --
988
989 CREATE TABLE IF NOT EXISTS icinga_servicechecks (
990   servicecheck_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
991   instance_id bigint unsigned default 0,
992   service_object_id bigint unsigned default 0,
993   check_type smallint default 0,
994   current_check_attempt smallint default 0,
995   max_check_attempts smallint default 0,
996   state smallint default 0,
997   state_type smallint default 0,
998   start_time timestamp  default '0000-00-00 00:00:00',
999   start_time_usec  int default 0,
1000   end_time timestamp  default '0000-00-00 00:00:00',
1001   end_time_usec  int default 0,
1002   command_object_id bigint unsigned default 0,
1003   command_args TEXT character set latin1  default '',
1004   command_line TEXT character set latin1  default '',
1005   timeout smallint default 0,
1006   early_timeout smallint default 0,
1007   execution_time double  default '0',
1008   latency double  default '0',
1009   return_code smallint default 0,
1010   output TEXT character set latin1  default '',
1011   long_output TEXT  default '',
1012   perfdata TEXT character set latin1  default '',
1013   PRIMARY KEY  (servicecheck_id)
1014 ) ENGINE=InnoDB  COMMENT='Historical service checks';
1015
1016 -- --------------------------------------------------------
1017
1018 --
1019 -- Table structure for table icinga_servicedependencies
1020 --
1021
1022 CREATE TABLE IF NOT EXISTS icinga_servicedependencies (
1023   servicedependency_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1024   instance_id bigint unsigned default 0,
1025   config_type smallint default 0,
1026   service_object_id bigint unsigned default 0,
1027   dependent_service_object_id bigint unsigned default 0,
1028   dependency_type smallint default 0,
1029   inherits_parent smallint default 0,
1030   timeperiod_object_id bigint unsigned default 0,
1031   fail_on_ok smallint default 0,
1032   fail_on_warning smallint default 0,
1033   fail_on_unknown smallint default 0,
1034   fail_on_critical smallint default 0,
1035   PRIMARY KEY  (servicedependency_id),
1036   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)
1037 ) ENGINE=InnoDB COMMENT='Service dependency definitions';
1038
1039 -- --------------------------------------------------------
1040
1041 --
1042 -- Table structure for table icinga_serviceescalations
1043 --
1044
1045 CREATE TABLE IF NOT EXISTS icinga_serviceescalations (
1046   serviceescalation_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1047   instance_id bigint unsigned default 0,
1048   config_type smallint default 0,
1049   service_object_id bigint unsigned default 0,
1050   timeperiod_object_id bigint unsigned default 0,
1051   first_notification smallint default 0,
1052   last_notification smallint default 0,
1053   notification_interval double  default '0',
1054   escalate_on_recovery smallint default 0,
1055   escalate_on_warning smallint default 0,
1056   escalate_on_unknown smallint default 0,
1057   escalate_on_critical smallint default 0,
1058   PRIMARY KEY  (serviceescalation_id),
1059   UNIQUE KEY instance_id (instance_id,config_type,service_object_id,timeperiod_object_id,first_notification,last_notification)
1060 ) ENGINE=InnoDB  COMMENT='Service escalation definitions';
1061
1062 -- --------------------------------------------------------
1063
1064 --
1065 -- Table structure for table icinga_serviceescalation_contactgroups
1066 --
1067
1068 CREATE TABLE IF NOT EXISTS icinga_serviceescalation_contactgroups (
1069   serviceescalation_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1070   instance_id bigint unsigned default 0,
1071   serviceescalation_id bigint unsigned default 0,
1072   contactgroup_object_id bigint unsigned default 0,
1073   PRIMARY KEY  (serviceescalation_contactgroup_id),
1074   UNIQUE KEY instance_id (serviceescalation_id,contactgroup_object_id)
1075 ) ENGINE=InnoDB  COMMENT='Service escalation contact groups';
1076
1077 -- --------------------------------------------------------
1078
1079 --
1080 -- Table structure for table icinga_serviceescalation_contacts
1081 --
1082
1083 CREATE TABLE IF NOT EXISTS icinga_serviceescalation_contacts (
1084   serviceescalation_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1085   instance_id bigint unsigned default 0,
1086   serviceescalation_id bigint unsigned default 0,
1087   contact_object_id bigint unsigned default 0,
1088   PRIMARY KEY  (serviceescalation_contact_id),
1089   UNIQUE KEY instance_id (instance_id,serviceescalation_id,contact_object_id)
1090 ) ENGINE=InnoDB  COMMENT='Service escalation contacts';
1091
1092 -- --------------------------------------------------------
1093
1094 --
1095 -- Table structure for table icinga_servicegroups
1096 --
1097
1098 CREATE TABLE IF NOT EXISTS icinga_servicegroups (
1099   servicegroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1100   instance_id bigint unsigned default 0,
1101   config_type smallint default 0,
1102   servicegroup_object_id bigint unsigned default 0,
1103   alias TEXT character set latin1  default '',
1104   notes TEXT character set latin1  default NULL,
1105   notes_url TEXT character set latin1  default NULL,
1106   action_url TEXT character set latin1  default NULL,
1107   PRIMARY KEY  (servicegroup_id),
1108   UNIQUE KEY instance_id (instance_id,config_type,servicegroup_object_id)
1109 ) ENGINE=InnoDB  COMMENT='Servicegroup definitions';
1110
1111 -- --------------------------------------------------------
1112
1113 --
1114 -- Table structure for table icinga_servicegroup_members
1115 --
1116
1117 CREATE TABLE IF NOT EXISTS icinga_servicegroup_members (
1118   servicegroup_member_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1119   instance_id bigint unsigned default 0,
1120   servicegroup_id bigint unsigned default 0,
1121   service_object_id bigint unsigned default 0,
1122   PRIMARY KEY  (servicegroup_member_id)
1123 ) ENGINE=InnoDB  COMMENT='Servicegroup members';
1124
1125 -- --------------------------------------------------------
1126
1127 --
1128 -- Table structure for table icinga_services
1129 --
1130
1131 CREATE TABLE IF NOT EXISTS icinga_services (
1132   service_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1133   instance_id bigint unsigned default 0,
1134   config_type smallint default 0,
1135   host_object_id bigint unsigned default 0,
1136   service_object_id bigint unsigned default 0,
1137   display_name varchar(255) character set latin1 collate latin1_general_cs  default '',
1138   check_command_object_id bigint unsigned default 0,
1139   check_command_args TEXT character set latin1  default '',
1140   eventhandler_command_object_id bigint unsigned default 0,
1141   eventhandler_command_args TEXT character set latin1  default '',
1142   notification_timeperiod_object_id bigint unsigned default 0,
1143   check_timeperiod_object_id bigint unsigned default 0,
1144   failure_prediction_options varchar(64) character set latin1  default '',
1145   check_interval double  default '0',
1146   retry_interval double  default '0',
1147   max_check_attempts smallint default 0,
1148   first_notification_delay double  default '0',
1149   notification_interval double  default '0',
1150   notify_on_warning smallint default 0,
1151   notify_on_unknown smallint default 0,
1152   notify_on_critical smallint default 0,
1153   notify_on_recovery smallint default 0,
1154   notify_on_flapping smallint default 0,
1155   notify_on_downtime smallint default 0,
1156   stalk_on_ok smallint default 0,
1157   stalk_on_warning smallint default 0,
1158   stalk_on_unknown smallint default 0,
1159   stalk_on_critical smallint default 0,
1160   is_volatile smallint default 0,
1161   flap_detection_enabled smallint default 0,
1162   flap_detection_on_ok smallint default 0,
1163   flap_detection_on_warning smallint default 0,
1164   flap_detection_on_unknown smallint default 0,
1165   flap_detection_on_critical smallint default 0,
1166   low_flap_threshold double  default '0',
1167   high_flap_threshold double  default '0',
1168   process_performance_data smallint default 0,
1169   freshness_checks_enabled smallint default 0,
1170   freshness_threshold int default 0,
1171   passive_checks_enabled smallint default 0,
1172   event_handler_enabled smallint default 0,
1173   active_checks_enabled smallint default 0,
1174   retain_status_information smallint default 0,
1175   retain_nonstatus_information smallint default 0,
1176   notifications_enabled smallint default 0,
1177   obsess_over_service smallint default 0,
1178   failure_prediction_enabled smallint default 0,
1179   notes TEXT character set latin1  default '',
1180   notes_url TEXT character set latin1  default '',
1181   action_url TEXT character set latin1  default '',
1182   icon_image TEXT character set latin1  default '',
1183   icon_image_alt TEXT character set latin1  default '',
1184   PRIMARY KEY  (service_id),
1185   UNIQUE KEY instance_id (instance_id,config_type,service_object_id),
1186   KEY service_object_id (service_object_id)
1187 ) ENGINE=InnoDB  COMMENT='Service definitions';
1188
1189 -- --------------------------------------------------------
1190
1191 --
1192 -- Table structure for table icinga_servicestatus
1193 --
1194
1195 CREATE TABLE IF NOT EXISTS icinga_servicestatus (
1196   servicestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1197   instance_id bigint unsigned default 0,
1198   service_object_id bigint unsigned default 0,
1199   status_update_time timestamp  default '0000-00-00 00:00:00',
1200   output TEXT character set latin1  default '',
1201   long_output TEXT  default '',
1202   perfdata TEXT character set latin1  default '',
1203   check_source TEXT character set latin1  default '',
1204   current_state smallint default 0,
1205   has_been_checked smallint default 0,
1206   should_be_scheduled smallint default 0,
1207   current_check_attempt smallint default 0,
1208   max_check_attempts smallint default 0,
1209   last_check timestamp  default '0000-00-00 00:00:00',
1210   next_check timestamp  default '0000-00-00 00:00:00',
1211   check_type smallint default 0,
1212   last_state_change timestamp  default '0000-00-00 00:00:00',
1213   last_hard_state_change timestamp  default '0000-00-00 00:00:00',
1214   last_hard_state smallint default 0,
1215   last_time_ok timestamp  default '0000-00-00 00:00:00',
1216   last_time_warning timestamp  default '0000-00-00 00:00:00',
1217   last_time_unknown timestamp  default '0000-00-00 00:00:00',
1218   last_time_critical timestamp  default '0000-00-00 00:00:00',
1219   state_type smallint default 0,
1220   last_notification timestamp  default '0000-00-00 00:00:00',
1221   next_notification timestamp  default '0000-00-00 00:00:00',
1222   no_more_notifications smallint default 0,
1223   notifications_enabled smallint default 0,
1224   problem_has_been_acknowledged smallint default 0,
1225   acknowledgement_type smallint default 0,
1226   current_notification_number smallint default 0,
1227   passive_checks_enabled smallint default 0,
1228   active_checks_enabled smallint default 0,
1229   event_handler_enabled smallint default 0,
1230   flap_detection_enabled smallint default 0,
1231   is_flapping smallint default 0,
1232   percent_state_change double  default '0',
1233   latency double  default '0',
1234   execution_time double  default '0',
1235   scheduled_downtime_depth smallint default 0,
1236   failure_prediction_enabled smallint default 0,
1237   process_performance_data smallint default 0,
1238   obsess_over_service smallint default 0,
1239   modified_service_attributes  int default 0,
1240   original_attributes TEXT character set latin1  default NULL,
1241   event_handler TEXT character set latin1  default '',
1242   check_command TEXT character set latin1  default '',
1243   normal_check_interval double  default '0',
1244   retry_check_interval double  default '0',
1245   check_timeperiod_object_id bigint unsigned default 0,
1246   is_reachable smallint default 0,
1247   PRIMARY KEY  (servicestatus_id),
1248   UNIQUE KEY object_id (service_object_id)
1249 ) ENGINE=InnoDB  COMMENT='Current service status information';
1250
1251 -- --------------------------------------------------------
1252
1253 --
1254 -- Table structure for table icinga_service_contactgroups
1255 --
1256
1257 CREATE TABLE IF NOT EXISTS icinga_service_contactgroups (
1258   service_contactgroup_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1259   instance_id bigint unsigned default 0,
1260   service_id bigint unsigned default 0,
1261   contactgroup_object_id bigint unsigned default 0,
1262   PRIMARY KEY  (service_contactgroup_id)
1263 ) ENGINE=InnoDB  COMMENT='Service contact groups';
1264
1265 -- --------------------------------------------------------
1266
1267 --
1268 -- Table structure for table icinga_service_contacts
1269 --
1270
1271 CREATE TABLE IF NOT EXISTS icinga_service_contacts (
1272   service_contact_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1273   instance_id bigint unsigned default 0,
1274   service_id bigint unsigned default 0,
1275   contact_object_id bigint unsigned default 0,
1276   PRIMARY KEY  (service_contact_id)
1277 ) ENGINE=InnoDB  COMMENT='Service contacts';
1278
1279 -- --------------------------------------------------------
1280
1281 --
1282 -- Table structure for table icinga_statehistory
1283 --
1284
1285 CREATE TABLE IF NOT EXISTS icinga_statehistory (
1286   statehistory_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1287   instance_id bigint unsigned default 0,
1288   state_time timestamp  default '0000-00-00 00:00:00',
1289   state_time_usec  int default 0,
1290   object_id bigint unsigned default 0,
1291   state_change smallint default 0,
1292   state smallint default 0,
1293   state_type smallint default 0,
1294   current_check_attempt smallint default 0,
1295   max_check_attempts smallint default 0,
1296   last_state smallint default 0,
1297   last_hard_state smallint default 0,
1298   output TEXT character set latin1  default '',
1299   long_output TEXT  default '',
1300   check_source varchar(255) character set latin1 default NULL,
1301   PRIMARY KEY  (statehistory_id)
1302 ) ENGINE=InnoDB COMMENT='Historical host and service state changes';
1303
1304 -- --------------------------------------------------------
1305
1306 --
1307 -- Table structure for table icinga_systemcommands
1308 --
1309
1310 CREATE TABLE IF NOT EXISTS icinga_systemcommands (
1311   systemcommand_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1312   instance_id bigint unsigned default 0,
1313   start_time timestamp  default '0000-00-00 00:00:00',
1314   start_time_usec  int default 0,
1315   end_time timestamp  default '0000-00-00 00:00:00',
1316   end_time_usec  int default 0,
1317   command_line TEXT character set latin1  default '',
1318   timeout smallint default 0,
1319   early_timeout smallint default 0,
1320   execution_time double  default '0',
1321   return_code smallint default 0,
1322   output TEXT character set latin1  default '',
1323   long_output TEXT  default '',
1324   PRIMARY KEY  (systemcommand_id),
1325   UNIQUE KEY instance_id (instance_id,start_time,start_time_usec)
1326 ) ENGINE=InnoDB  COMMENT='Historical system commands that are executed';
1327
1328 -- --------------------------------------------------------
1329
1330 --
1331 -- Table structure for table icinga_timeperiods
1332 --
1333
1334 CREATE TABLE IF NOT EXISTS icinga_timeperiods (
1335   timeperiod_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1336   instance_id bigint unsigned default 0,
1337   config_type smallint default 0,
1338   timeperiod_object_id bigint unsigned default 0,
1339   alias TEXT character set latin1  default '',
1340   PRIMARY KEY  (timeperiod_id),
1341   UNIQUE KEY instance_id (instance_id,config_type,timeperiod_object_id)
1342 ) ENGINE=InnoDB  COMMENT='Timeperiod definitions';
1343
1344 -- --------------------------------------------------------
1345
1346 --
1347 -- Table structure for table icinga_timeperiod_timeranges
1348 --
1349
1350 CREATE TABLE IF NOT EXISTS icinga_timeperiod_timeranges (
1351   timeperiod_timerange_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1352   instance_id bigint unsigned default 0,
1353   timeperiod_id bigint unsigned default 0,
1354   day smallint default 0,
1355   start_sec  int default 0,
1356   end_sec  int default 0,
1357   PRIMARY KEY  (timeperiod_timerange_id)
1358 ) ENGINE=InnoDB  COMMENT='Timeperiod definitions';
1359
1360
1361 -- --------------------------------------------------------
1362 -- Icinga 2 specific schema extensions
1363 -- --------------------------------------------------------
1364
1365 --
1366 -- Table structure for table icinga_endpoints
1367 --
1368
1369 CREATE TABLE IF NOT EXISTS icinga_endpoints (
1370   endpoint_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1371   instance_id bigint unsigned default 0,
1372   endpoint_object_id bigint(20) unsigned DEFAULT '0',
1373   zone_object_id bigint(20) unsigned DEFAULT '0',
1374   config_type smallint(6) DEFAULT '0',
1375   identity varchar(255) DEFAULT NULL,
1376   node varchar(255) DEFAULT NULL,
1377   PRIMARY KEY  (endpoint_id)
1378 ) ENGINE=InnoDB COMMENT='Endpoint configuration';
1379
1380 -- --------------------------------------------------------
1381
1382 --
1383 -- Table structure for table icinga_endpointstatus
1384 --
1385
1386 CREATE TABLE IF NOT EXISTS icinga_endpointstatus (
1387   endpointstatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1388   instance_id bigint unsigned default 0,
1389   endpoint_object_id bigint(20) unsigned DEFAULT '0',
1390   zone_object_id bigint(20) unsigned DEFAULT '0',
1391   status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
1392   identity varchar(255) DEFAULT NULL,
1393   node varchar(255) DEFAULT NULL,
1394   is_connected smallint(6),
1395   PRIMARY KEY  (endpointstatus_id)
1396 ) ENGINE=InnoDB COMMENT='Endpoint status';
1397
1398 --
1399 -- Table structure for table icinga_zones
1400 --
1401
1402 CREATE TABLE IF NOT EXISTS icinga_zones (
1403   zone_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1404   instance_id bigint unsigned default 0,
1405   zone_object_id bigint(20) unsigned DEFAULT '0',
1406   config_type smallint(6) DEFAULT '0',
1407   parent_zone_object_id bigint(20) unsigned DEFAULT '0',
1408   is_global smallint(6),
1409   PRIMARY KEY  (zone_id)
1410 ) ENGINE=InnoDB COMMENT='Zone configuration';
1411
1412 -- --------------------------------------------------------
1413
1414 --
1415 -- Table structure for table icinga_zonestatus
1416 --
1417
1418 CREATE TABLE IF NOT EXISTS icinga_zonestatus (
1419   zonestatus_id bigint(20) unsigned NOT NULL AUTO_INCREMENT,
1420   instance_id bigint unsigned default 0,
1421   zone_object_id bigint(20) unsigned DEFAULT '0',
1422   status_update_time timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
1423   parent_zone_object_id bigint(20) unsigned DEFAULT '0',
1424   PRIMARY KEY  (zonestatus_id)
1425 ) ENGINE=InnoDB COMMENT='Zone status';
1426
1427
1428
1429
1430 ALTER TABLE icinga_servicestatus ADD COLUMN endpoint_object_id bigint default NULL;
1431 ALTER TABLE icinga_hoststatus ADD COLUMN endpoint_object_id bigint default NULL;
1432 ALTER TABLE icinga_contactstatus ADD COLUMN endpoint_object_id bigint default NULL;
1433 ALTER TABLE icinga_programstatus ADD COLUMN endpoint_object_id bigint default NULL;
1434 ALTER TABLE icinga_comments ADD COLUMN endpoint_object_id bigint default NULL;
1435 ALTER TABLE icinga_scheduleddowntime ADD COLUMN endpoint_object_id bigint default NULL;
1436 ALTER TABLE icinga_runtimevariables ADD COLUMN endpoint_object_id bigint default NULL;
1437 ALTER TABLE icinga_customvariablestatus ADD COLUMN endpoint_object_id bigint default NULL;
1438
1439 ALTER TABLE icinga_acknowledgements ADD COLUMN endpoint_object_id bigint default NULL;
1440 ALTER TABLE icinga_commenthistory ADD COLUMN endpoint_object_id bigint default NULL;
1441 ALTER TABLE icinga_contactnotifications ADD COLUMN endpoint_object_id bigint default NULL;
1442 ALTER TABLE icinga_downtimehistory ADD COLUMN endpoint_object_id bigint default NULL;
1443 ALTER TABLE icinga_eventhandlers ADD COLUMN endpoint_object_id bigint default NULL;
1444 ALTER TABLE icinga_externalcommands ADD COLUMN endpoint_object_id bigint default NULL;
1445 ALTER TABLE icinga_flappinghistory ADD COLUMN endpoint_object_id bigint default NULL;
1446 ALTER TABLE icinga_hostchecks ADD COLUMN endpoint_object_id bigint default NULL;
1447 ALTER TABLE icinga_logentries ADD COLUMN endpoint_object_id bigint default NULL;
1448 ALTER TABLE icinga_notifications ADD COLUMN endpoint_object_id bigint default NULL;
1449 ALTER TABLE icinga_processevents ADD COLUMN endpoint_object_id bigint default NULL;
1450 ALTER TABLE icinga_servicechecks ADD COLUMN endpoint_object_id bigint default NULL;
1451 ALTER TABLE icinga_statehistory ADD COLUMN endpoint_object_id bigint default NULL;
1452 ALTER TABLE icinga_systemcommands ADD COLUMN endpoint_object_id bigint default NULL;
1453
1454 -- -----------------------------------------
1455 -- add index (delete)
1456 -- -----------------------------------------
1457
1458 -- for periodic delete 
1459 -- instance_id and
1460 -- SYSTEMCOMMANDS, SERVICECHECKS, HOSTCHECKS, EVENTHANDLERS  => start_time
1461 -- EXTERNALCOMMANDS => entry_time
1462
1463 -- instance_id
1464 CREATE INDEX systemcommands_i_id_idx on icinga_systemcommands(instance_id);
1465 CREATE INDEX servicechecks_i_id_idx on icinga_servicechecks(instance_id);
1466 CREATE INDEX hostchecks_i_id_idx on icinga_hostchecks(instance_id);
1467 CREATE INDEX eventhandlers_i_id_idx on icinga_eventhandlers(instance_id);
1468 CREATE INDEX externalcommands_i_id_idx on icinga_externalcommands(instance_id);
1469
1470 -- time
1471 CREATE INDEX systemcommands_time_id_idx on icinga_systemcommands(start_time);
1472 CREATE INDEX servicechecks_time_id_idx on icinga_servicechecks(start_time);
1473 CREATE INDEX hostchecks_time_id_idx on icinga_hostchecks(start_time);
1474 CREATE INDEX eventhandlers_time_id_idx on icinga_eventhandlers(start_time);
1475 CREATE INDEX externalcommands_time_id_idx on icinga_externalcommands(entry_time);
1476
1477
1478 -- for starting cleanup - referenced in dbhandler.c:882
1479 -- instance_id only
1480
1481 -- realtime data
1482 CREATE INDEX programstatus_i_id_idx on icinga_programstatus(instance_id);
1483 CREATE INDEX hoststatus_i_id_idx on icinga_hoststatus(instance_id);
1484 CREATE INDEX servicestatus_i_id_idx on icinga_servicestatus(instance_id);
1485 CREATE INDEX contactstatus_i_id_idx on icinga_contactstatus(instance_id);
1486 CREATE INDEX comments_i_id_idx on icinga_comments(instance_id);
1487 CREATE INDEX scheduleddowntime_i_id_idx on icinga_scheduleddowntime(instance_id);
1488 CREATE INDEX runtimevariables_i_id_idx on icinga_runtimevariables(instance_id);
1489 CREATE INDEX customvariablestatus_i_id_idx on icinga_customvariablestatus(instance_id);
1490
1491 -- config data
1492 CREATE INDEX configfiles_i_id_idx on icinga_configfiles(instance_id);
1493 CREATE INDEX configfilevariables_i_id_idx on icinga_configfilevariables(instance_id);
1494 CREATE INDEX customvariables_i_id_idx on icinga_customvariables(instance_id);
1495 CREATE INDEX commands_i_id_idx on icinga_commands(instance_id);
1496 CREATE INDEX timeperiods_i_id_idx on icinga_timeperiods(instance_id);
1497 CREATE INDEX timeperiod_timeranges_i_id_idx on icinga_timeperiod_timeranges(instance_id);
1498 CREATE INDEX contactgroups_i_id_idx on icinga_contactgroups(instance_id);
1499 CREATE INDEX contactgroup_members_i_id_idx on icinga_contactgroup_members(instance_id);
1500 CREATE INDEX hostgroups_i_id_idx on icinga_hostgroups(instance_id);
1501 CREATE INDEX hostgroup_members_i_id_idx on icinga_hostgroup_members(instance_id);
1502 CREATE INDEX servicegroups_i_id_idx on icinga_servicegroups(instance_id);
1503 CREATE INDEX servicegroup_members_i_id_idx on icinga_servicegroup_members(instance_id);
1504 CREATE INDEX hostesc_i_id_idx on icinga_hostescalations(instance_id);
1505 CREATE INDEX hostesc_contacts_i_id_idx on icinga_hostescalation_contacts(instance_id);
1506 CREATE INDEX serviceesc_i_id_idx on icinga_serviceescalations(instance_id);
1507 CREATE INDEX serviceesc_contacts_i_id_idx on icinga_serviceescalation_contacts(instance_id);
1508 CREATE INDEX hostdependencies_i_id_idx on icinga_hostdependencies(instance_id);
1509 CREATE INDEX contacts_i_id_idx on icinga_contacts(instance_id);
1510 CREATE INDEX contact_addresses_i_id_idx on icinga_contact_addresses(instance_id);
1511 CREATE INDEX contact_notifcommands_i_id_idx on icinga_contact_notificationcommands(instance_id);
1512 CREATE INDEX hosts_i_id_idx on icinga_hosts(instance_id);
1513 CREATE INDEX host_parenthosts_i_id_idx on icinga_host_parenthosts(instance_id);
1514 CREATE INDEX host_contacts_i_id_idx on icinga_host_contacts(instance_id);
1515 CREATE INDEX services_i_id_idx on icinga_services(instance_id);
1516 CREATE INDEX service_contacts_i_id_idx on icinga_service_contacts(instance_id);
1517 CREATE INDEX service_contactgroups_i_id_idx on icinga_service_contactgroups(instance_id);
1518 CREATE INDEX host_contactgroups_i_id_idx on icinga_host_contactgroups(instance_id);
1519 CREATE INDEX hostesc_cgroups_i_id_idx on icinga_hostescalation_contactgroups(instance_id);
1520 CREATE INDEX serviceesc_cgroups_i_id_idx on icinga_serviceescalation_contactgroups(instance_id);
1521
1522 -- -----------------------------------------
1523 -- more index stuff (WHERE clauses)
1524 -- -----------------------------------------
1525
1526 -- hosts
1527 CREATE INDEX hosts_host_object_id_idx on icinga_hosts(host_object_id);
1528
1529 -- hoststatus
1530 CREATE INDEX hoststatus_stat_upd_time_idx on icinga_hoststatus(status_update_time);
1531 CREATE INDEX hoststatus_current_state_idx on icinga_hoststatus(current_state);
1532 CREATE INDEX hoststatus_check_type_idx on icinga_hoststatus(check_type);
1533 CREATE INDEX hoststatus_state_type_idx on icinga_hoststatus(state_type);
1534 CREATE INDEX hoststatus_last_state_chg_idx on icinga_hoststatus(last_state_change);
1535 CREATE INDEX hoststatus_notif_enabled_idx on icinga_hoststatus(notifications_enabled);
1536 CREATE INDEX hoststatus_problem_ack_idx on icinga_hoststatus(problem_has_been_acknowledged);
1537 CREATE INDEX hoststatus_act_chks_en_idx on icinga_hoststatus(active_checks_enabled);
1538 CREATE INDEX hoststatus_pas_chks_en_idx on icinga_hoststatus(passive_checks_enabled);
1539 CREATE INDEX hoststatus_event_hdl_en_idx on icinga_hoststatus(event_handler_enabled);
1540 CREATE INDEX hoststatus_flap_det_en_idx on icinga_hoststatus(flap_detection_enabled);
1541 CREATE INDEX hoststatus_is_flapping_idx on icinga_hoststatus(is_flapping);
1542 CREATE INDEX hoststatus_p_state_chg_idx on icinga_hoststatus(percent_state_change);
1543 CREATE INDEX hoststatus_latency_idx on icinga_hoststatus(latency);
1544 CREATE INDEX hoststatus_ex_time_idx on icinga_hoststatus(execution_time);
1545 CREATE INDEX hoststatus_sch_downt_d_idx on icinga_hoststatus(scheduled_downtime_depth);
1546
1547 -- services
1548 CREATE INDEX services_host_object_id_idx on icinga_services(host_object_id);
1549
1550 -- servicestatus
1551 CREATE INDEX srvcstatus_stat_upd_time_idx on icinga_servicestatus(status_update_time);
1552 CREATE INDEX srvcstatus_current_state_idx on icinga_servicestatus(current_state);
1553 CREATE INDEX srvcstatus_check_type_idx on icinga_servicestatus(check_type);
1554 CREATE INDEX srvcstatus_state_type_idx on icinga_servicestatus(state_type);
1555 CREATE INDEX srvcstatus_last_state_chg_idx on icinga_servicestatus(last_state_change);
1556 CREATE INDEX srvcstatus_notif_enabled_idx on icinga_servicestatus(notifications_enabled);
1557 CREATE INDEX srvcstatus_problem_ack_idx on icinga_servicestatus(problem_has_been_acknowledged);
1558 CREATE INDEX srvcstatus_act_chks_en_idx on icinga_servicestatus(active_checks_enabled);
1559 CREATE INDEX srvcstatus_pas_chks_en_idx on icinga_servicestatus(passive_checks_enabled);
1560 CREATE INDEX srvcstatus_event_hdl_en_idx on icinga_servicestatus(event_handler_enabled);
1561 CREATE INDEX srvcstatus_flap_det_en_idx on icinga_servicestatus(flap_detection_enabled);
1562 CREATE INDEX srvcstatus_is_flapping_idx on icinga_servicestatus(is_flapping);
1563 CREATE INDEX srvcstatus_p_state_chg_idx on icinga_servicestatus(percent_state_change);
1564 CREATE INDEX srvcstatus_latency_idx on icinga_servicestatus(latency);
1565 CREATE INDEX srvcstatus_ex_time_idx on icinga_servicestatus(execution_time);
1566 CREATE INDEX srvcstatus_sch_downt_d_idx on icinga_servicestatus(scheduled_downtime_depth);
1567
1568 -- hostchecks
1569 CREATE INDEX hostchks_h_obj_id_idx on icinga_hostchecks(host_object_id);
1570
1571 -- servicechecks
1572 CREATE INDEX servicechks_s_obj_id_idx on icinga_servicechecks(service_object_id);
1573
1574 -- objects
1575 CREATE INDEX objects_objtype_id_idx ON icinga_objects(objecttype_id);
1576 CREATE INDEX objects_name1_idx ON icinga_objects(name1);
1577 CREATE INDEX objects_name2_idx ON icinga_objects(name2);
1578 CREATE INDEX objects_inst_id_idx ON icinga_objects(instance_id);
1579
1580 -- instances
1581 -- CREATE INDEX instances_name_idx on icinga_instances(instance_name);
1582
1583 -- logentries
1584 -- CREATE INDEX loge_instance_id_idx on icinga_logentries(instance_id);
1585 -- #236
1586 CREATE INDEX loge_time_idx on icinga_logentries(logentry_time);
1587 -- CREATE INDEX loge_data_idx on icinga_logentries(logentry_data);
1588 CREATE INDEX loge_inst_id_time_idx on icinga_logentries (instance_id ASC, logentry_time DESC);
1589
1590 -- commenthistory
1591 -- CREATE INDEX c_hist_instance_id_idx on icinga_logentries(instance_id);
1592 -- CREATE INDEX c_hist_c_time_idx on icinga_logentries(comment_time);
1593 -- CREATE INDEX c_hist_i_c_id_idx on icinga_logentries(internal_comment_id);
1594
1595 -- downtimehistory
1596 -- CREATE INDEX d_t_hist_nstance_id_idx on icinga_downtimehistory(instance_id);
1597 -- CREATE INDEX d_t_hist_type_idx on icinga_downtimehistory(downtime_type);
1598 -- CREATE INDEX d_t_hist_object_id_idx on icinga_downtimehistory(object_id);
1599 -- CREATE INDEX d_t_hist_entry_time_idx on icinga_downtimehistory(entry_time);
1600 -- CREATE INDEX d_t_hist_sched_start_idx on icinga_downtimehistory(scheduled_start_time);
1601 -- CREATE INDEX d_t_hist_sched_end_idx on icinga_downtimehistory(scheduled_end_time);
1602
1603 -- scheduleddowntime
1604 -- CREATE INDEX sched_d_t_downtime_type_idx on icinga_scheduleddowntime(downtime_type);
1605 -- CREATE INDEX sched_d_t_object_id_idx on icinga_scheduleddowntime(object_id);
1606 -- CREATE INDEX sched_d_t_entry_time_idx on icinga_scheduleddowntime(entry_time);
1607 -- CREATE INDEX sched_d_t_start_time_idx on icinga_scheduleddowntime(scheduled_start_time);
1608 -- CREATE INDEX sched_d_t_end_time_idx on icinga_scheduleddowntime(scheduled_end_time);
1609
1610 -- statehistory
1611 CREATE INDEX statehist_i_id_o_id_s_ty_s_ti on icinga_statehistory(instance_id, object_id, state_type, state_time);
1612 --#2274
1613 create index statehist_state_idx on icinga_statehistory(object_id,state);
1614
1615
1616 -- Icinga Web Notifications
1617 CREATE INDEX notification_idx ON icinga_notifications(notification_type, object_id, start_time);
1618 CREATE INDEX notification_object_id_idx ON icinga_notifications(object_id);
1619 CREATE INDEX contact_notification_idx ON icinga_contactnotifications(notification_id, contact_object_id);
1620 CREATE INDEX contacts_object_id_idx ON icinga_contacts(contact_object_id);
1621 CREATE INDEX contact_notif_meth_notif_idx ON icinga_contactnotificationmethods(contactnotification_id, command_object_id);
1622 CREATE INDEX command_object_idx ON icinga_commands(object_id); 
1623 CREATE INDEX services_combined_object_idx ON icinga_services(service_object_id, host_object_id);
1624
1625
1626 -- #2618
1627 CREATE INDEX cntgrpmbrs_cgid_coid ON icinga_contactgroup_members (contactgroup_id,contact_object_id);
1628 CREATE INDEX hstgrpmbrs_hgid_hoid ON icinga_hostgroup_members (hostgroup_id,host_object_id);
1629 CREATE INDEX hstcntgrps_hid_cgoid ON icinga_host_contactgroups (host_id,contactgroup_object_id);
1630 CREATE INDEX hstprnthsts_hid_phoid ON icinga_host_parenthosts (host_id,parent_host_object_id);
1631 CREATE INDEX runtimevars_iid_varn ON icinga_runtimevariables (instance_id,varname);
1632 CREATE INDEX sgmbrs_sgid_soid ON icinga_servicegroup_members (servicegroup_id,service_object_id);
1633 CREATE INDEX scgrps_sid_cgoid ON icinga_service_contactgroups (service_id,contactgroup_object_id);
1634 CREATE INDEX tperiod_tid_d_ss_es ON icinga_timeperiod_timeranges (timeperiod_id,day,start_sec,end_sec);
1635
1636 -- #3649
1637 CREATE INDEX sla_idx_sthist ON icinga_statehistory (object_id, state_time DESC);
1638 CREATE INDEX sla_idx_dohist ON icinga_downtimehistory (object_id, actual_start_time, actual_end_time);
1639 CREATE INDEX sla_idx_obj ON icinga_objects (objecttype_id, is_active, name1);
1640
1641 -- #4985
1642 CREATE INDEX commenthistory_delete_idx ON icinga_commenthistory (instance_id, comment_time, internal_comment_id);
1643
1644 -- #10436
1645 CREATE INDEX cv_session_del_idx ON icinga_customvariables (session_token);
1646 CREATE INDEX cvs_session_del_idx ON icinga_customvariablestatus (session_token);
1647
1648 -- -----------------------------------------
1649 -- set dbversion
1650 -- -----------------------------------------
1651 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();
1652
1653