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