]> granicus.if.org Git - icinga2/blob - doc/4-advanced-topics.md
Documentation: Enhance cluster troubleshooting; add HA command_endpoint
[icinga2] / doc / 4-advanced-topics.md
1 # <a id="advanced-topics"></a> Advanced Topics
2
3 This chapter covers a number of advanced topics. If you're new to Icinga you
4 can safely skip over things you're not interested in.
5
6 ## <a id="downtimes"></a> Downtimes
7
8 Downtimes can be scheduled for planned server maintenance or
9 any other targetted service outage you are aware of in advance.
10
11 Downtimes will suppress any notifications, and may trigger other
12 downtimes too. If the downtime was set by accident, or the duration
13 exceeds the maintenance, you can manually cancel the downtime.
14 Planned downtimes will also be taken into account for SLA reporting
15 tools calculating the SLAs based on the state and downtime history.
16
17 Multiple downtimes for a single object may overlap. This is useful
18 when you want to extend your maintenance window taking longer than expected.
19 If there are multiple downtimes triggered for one object, the overall downtime depth
20 will be greater than `1`.
21
22
23 If the downtime was scheduled after the problem changed to a critical hard
24 state triggering a problem notification, and the service recovers during
25 the downtime window, the recovery notification won't be suppressed.
26
27 ### <a id="fixed-flexible-downtimes"></a> Fixed and Flexible Downtimes
28
29 A `fixed` downtime will be activated at the defined start time, and
30 removed at the end time. During this time window the service state
31 will change to `NOT-OK` and then actually trigger the downtime.
32 Notifications are suppressed and the downtime depth is incremented.
33
34 Common scenarios are a planned distribution upgrade on your linux
35 servers, or database updates in your warehouse. The customer knows
36 about a fixed downtime window between 23:00 and 24:00. After 24:00
37 all problems should be alerted again. Solution is simple -
38 schedule a `fixed` downtime starting at 23:00 and ending at 24:00.
39
40 Unlike a `fixed` downtime, a `flexible` downtime will be triggered
41 by the state change in the time span defined by start and end time,
42 and then last for the specified duration in minutes.
43
44 Imagine the following scenario: Your service is frequently polled
45 by users trying to grab free deleted domains for immediate registration.
46 Between 07:30 and 08:00 the impact will hit for 15 minutes and generate
47 a network outage visible to the monitoring. The service is still alive,
48 but answering too slow to Icinga 2 service checks.
49 For that reason, you may want to schedule a downtime between 07:30 and
50 08:00 with a duration of 15 minutes. The downtime will then last from
51 its trigger time until the duration is over. After that, the downtime
52 is removed (may happen before or after the actual end time!).
53
54 ### <a id="scheduling-downtime"></a> Scheduling a downtime
55
56 This can either happen through a web interface or by sending an [external command](4-advanced-topics.md#external-commands)
57 to the external command pipe provided by the `ExternalCommandListener` configuration.
58
59 Fixed downtimes require a start and end time (a duration will be ignored).
60 Flexible downtimes need a start and end time for the time span, and a duration
61 independent from that time span.
62
63 ### <a id="triggered-downtimes"></a> Triggered Downtimes
64
65 This is optional when scheduling a downtime. If there is already a downtime
66 scheduled for a future maintenance, the current downtime can be triggered by
67 that downtime. This renders useful if you have scheduled a host downtime and
68 are now scheduling a child host's downtime getting triggered by the parent
69 downtime on NOT-OK state change.
70
71 ### <a id="recurring-downtimes"></a> Recurring Downtimes
72
73 [ScheduledDowntime objects](6-object-types.md#objecttype-scheduleddowntime) can be used to set up
74 recurring downtimes for services.
75
76 Example:
77
78     apply ScheduledDowntime "backup-downtime" to Service {
79       author = "icingaadmin"
80       comment = "Scheduled downtime for backup"
81
82       ranges = {
83         monday = "02:00-03:00"
84         tuesday = "02:00-03:00"
85         wednesday = "02:00-03:00"
86         thursday = "02:00-03:00"
87         friday = "02:00-03:00"
88         saturday = "02:00-03:00"
89         sunday = "02:00-03:00"
90       }
91
92       assign where "backup" in service.groups
93     }
94
95
96 ## <a id="comments-intro"></a> Comments
97
98 Comments can be added at runtime and are persistent over restarts. You can
99 add useful information for others on repeating incidents (for example
100 "last time syslog at 100% cpu on 17.10.2013 due to stale nfs mount") which
101 is primarly accessible using web interfaces.
102
103 Adding and deleting comment actions are possible through the external command pipe
104 provided with the `ExternalCommandListener` configuration. The caller must
105 pass the comment id in case of manipulating an existing comment.
106
107
108 ## <a id="acknowledgements"></a> Acknowledgements
109
110 If a problem is alerted and notified you may signal the other notification
111 recipients that you are aware of the problem and will handle it.
112
113 By sending an acknowledgement to Icinga 2 (using the external command pipe
114 provided with `ExternalCommandListener` configuration) all future notifications
115 are suppressed, a new comment is added with the provided description and
116 a notification with the type `NotificationFilterAcknowledgement` is sent
117 to all notified users.
118
119 ### <a id="expiring-acknowledgements"></a> Expiring Acknowledgements
120
121 Once a problem is acknowledged it may disappear from your `handled problems`
122 dashboard and no-one ever looks at it again since it will suppress
123 notifications too.
124
125 This `fire-and-forget` action is quite common. If you're sure that a
126 current problem should be resolved in the future at a defined time,
127 you can define an expiration time when acknowledging the problem.
128
129 Icinga 2 will clear the acknowledgement when expired and start to
130 re-notify if the problem persists.
131
132
133 ## <a id="timeperiods"></a> Time Periods
134
135 Time Periods define time ranges in Icinga where event actions are
136 triggered, for example whether a service check is executed or not within
137 the `check_period` attribute. Or a notification should be sent to
138 users or not, filtered by the `period` and `notification_period`
139 configuration attributes for `Notification` and `User` objects.
140
141 > **Note**
142 >
143 > If you are familar with Icinga 1.x - these time period definitions
144 > are called `legacy timeperiods` in Icinga 2.
145 >
146 > An Icinga 2 legacy timeperiod requires the `ITL` provided template
147 >`legacy-timeperiod`.
148
149 The `TimePeriod` attribute `ranges` may contain multiple directives,
150 including weekdays, days of the month, and calendar dates.
151 These types may overlap/override other types in your ranges dictionary.
152
153 The descending order of precedence is as follows:
154
155 * Calendar date (2008-01-01)
156 * Specific month date (January 1st)
157 * Generic month date (Day 15)
158 * Offset weekday of specific month (2nd Tuesday in December)
159 * Offset weekday (3rd Monday)
160 * Normal weekday (Tuesday)
161
162 If you don't set any `check_period` or `notification_period` attribute
163 on your configuration objects Icinga 2 assumes `24x7` as time period
164 as shown below.
165
166     object TimePeriod "24x7" {
167       import "legacy-timeperiod"
168
169       display_name = "Icinga 2 24x7 TimePeriod"
170       ranges = {
171         "monday"    = "00:00-24:00"
172         "tuesday"   = "00:00-24:00"
173         "wednesday" = "00:00-24:00"
174         "thursday"  = "00:00-24:00"
175         "friday"    = "00:00-24:00"
176         "saturday"  = "00:00-24:00"
177         "sunday"    = "00:00-24:00"
178       }
179     }
180
181 If your operation staff should only be notified during workhours
182 create a new timeperiod named `workhours` defining a work day from
183 09:00 to 17:00.
184
185     object TimePeriod "workhours" {
186       import "legacy-timeperiod"
187
188       display_name = "Icinga 2 8x5 TimePeriod"
189       ranges = {
190         "monday"    = "09:00-17:00"
191         "tuesday"   = "09:00-17:00"
192         "wednesday" = "09:00-17:00"
193         "thursday"  = "09:00-17:00"
194         "friday"    = "09:00-17:00"
195       }
196     }
197
198 Use the `period` attribute to assign time periods to
199 `Notification` and `Dependency` objects:
200
201     object Notification "mail" {
202       import "generic-notification"
203
204       host_name = "localhost"
205
206       command = "mail-notification"
207       users = [ "icingaadmin" ]
208       period = "workhours"
209     }
210
211 ## <a id="access-object-attributes-at-runtime"></a> Access Object Attributes at Runtime
212
213 The [Object Accessor Functions](20-library-reference.md#object-accessor-functions)
214 can be used to retrieve references to other objects by name.
215
216 This allows you to access configuration and runtime object attributes. A detailed
217 list can be found [here](6-object-types.md#object-types).
218
219 Simple cluster example for accessing two host object states and calculating a virtual
220 cluster state and output:
221
222     object Host "cluster-host-01" {
223       check_command = "dummy"
224       vars.dummy_state = 2
225       vars.dummy_text = "This host is down."
226     }
227
228     object Host "cluster-host-02" {
229       check_command = "dummy"
230       vars.dummy_state = 0
231       vars.dummy_text = "This host is up."
232     }
233
234     object Host "cluster" {
235       check_command = "dummy"
236       vars.cluster_nodes = [ "cluster-host-01", "cluster-host-02" ]
237
238       vars.dummy_state = {{
239         var up_count = 0
240         var down_count = 0
241         var cluster_nodes = macro("$cluster_nodes$")
242
243         for (node in cluster_nodes) {
244           if (get_host(node).state > 0) {
245             down_count += 1
246           } else {
247             up_count += 1
248           }
249         }
250
251         if (up_count >= down_count) {
252           return 0 //same up as down -> UP
253         } else {
254           return 1 //something is broken
255         }
256       }}
257
258       vars.dummy_text = {{
259         var output = "Cluster hosts:\n"
260         var cluster_nodes = macro("$cluster_nodes$")
261
262         for (node in cluster_nodes) {
263           output += node + ": " + get_host(node).last_check_result.output + "\n"
264         }
265
266         return output
267       }}
268     }
269
270
271 The following example sets time dependent thresholds for the load check based on the current
272 time of the day compared to the defined time period.
273
274     object TimePeriod "backup" {
275       import "legacy-timeperiod"
276
277       ranges = {
278         monday = "02:00-03:00"
279         tuesday = "02:00-03:00"
280         wednesday = "02:00-03:00"
281         thursday = "02:00-03:00"
282         friday = "02:00-03:00"
283         saturday = "02:00-03:00"
284         sunday = "02:00-03:00"
285       }
286     }
287
288     object Host "webserver-with-backup" {
289       check_command = "hostalive"
290       address = "127.0.0.1"
291     }
292
293     object Service "webserver-backup-load" {
294       check_command = "load"
295       host_name = "webserver-with-backup"
296
297       vars.load_wload1 = {{
298         if (get_time_period("backup").is_inside) {
299           return 20
300         } else {
301           return 5
302         }
303       }}
304       vars.load_cload1 = {{
305         if (get_time_period("backup").is_inside) {
306           return 40
307         } else {
308           return 10
309         }
310       }}
311     }
312
313
314 ## <a id="check-result-freshness"></a> Check Result Freshness
315
316 In Icinga 2 active check freshness is enabled by default. It is determined by the
317 `check_interval` attribute and no incoming check results in that period of time.
318
319     threshold = last check execution time + check interval
320
321 Passive check freshness is calculated from the `check_interval` attribute if set.
322
323     threshold = last check result time + check interval
324
325 If the freshness checks are invalid, a new check is executed defined by the
326 `check_command` attribute.
327
328
329 ## <a id="check-flapping"></a> Check Flapping
330
331 The flapping algorithm used in Icinga 2 does not store the past states but
332 calculcates the flapping threshold from a single value based on counters and
333 half-life values. Icinga 2 compares the value with a single flapping threshold
334 configuration attribute named `flapping_threshold`.
335
336 Flapping detection can be enabled or disabled using the `enable_flapping` attribute.
337
338
339 ## <a id="volatile-services"></a> Volatile Services
340
341 By default all services remain in a non-volatile state. When a problem
342 occurs, the `SOFT` state applies and once `max_check_attempts` attribute
343 is reached with the check counter, a `HARD` state transition happens.
344 Notifications are only triggered by `HARD` state changes and are then
345 re-sent defined by the `interval` attribute.
346
347 It may be reasonable to have a volatile service which stays in a `HARD`
348 state type if the service stays in a `NOT-OK` state. That way each
349 service recheck will automatically trigger a notification unless the
350 service is acknowledged or in a scheduled downtime.
351
352
353 ## <a id="external-commands"></a> External Commands
354
355 Icinga 2 provides an external command pipe for processing commands
356 triggering specific actions (for example rescheduling a service check
357 through the web interface).
358
359 In order to enable the `ExternalCommandListener` configuration use the
360 following command and restart Icinga 2 afterwards:
361
362     # icinga2 feature enable command
363
364 Icinga 2 creates the command pipe file as `/var/run/icinga2/cmd/icinga2.cmd`
365 using the default configuration.
366
367 Web interfaces and other Icinga addons are able to send commands to
368 Icinga 2 through the external command pipe, for example for rescheduling
369 a forced service check:
370
371     # /bin/echo "[`date +%s`] SCHEDULE_FORCED_SVC_CHECK;localhost;ping4;`date +%s`" >> /var/run/icinga2/cmd/icinga2.cmd
372
373     # tail -f /var/log/messages
374
375     Oct 17 15:01:25 icinga-server icinga2: Executing external command: [1382014885] SCHEDULE_FORCED_SVC_CHECK;localhost;ping4;1382014885
376     Oct 17 15:01:25 icinga-server icinga2: Rescheduling next check for service 'ping4'
377
378 A list of currently supported external commands can be found [here](22-appendix.md#external-commands-list-detail).
379
380 Detailed information on the commands and their required parameters can be found
381 on the [Icinga 1.x documentation](http://docs.icinga.org/latest/en/extcommands2.html).
382
383 ## <a id="logging"></a> Logging
384
385 Icinga 2 supports three different types of logging:
386
387 * File logging
388 * Syslog (on *NIX-based operating systems)
389 * Console logging (`STDOUT` on tty)
390
391 You can enable additional loggers using the `icinga2 feature enable`
392 and `icinga2 feature disable` commands to configure loggers:
393
394 Feature  | Description
395 ---------|------------
396 debuglog | Debug log (path: `/var/log/icinga2/debug.log`, severity: `debug` or higher)
397 mainlog  | Main log (path: `/var/log/icinga2/icinga2.log`, severity: `information` or higher)
398 syslog   | Syslog (severity: `warning` or higher)
399
400 By default file the `mainlog` feature is enabled. When running Icinga 2
401 on a terminal log messages with severity `information` or higher are
402 written to the console.
403
404 ## <a id="performance-data"></a> Performance Data
405
406 When a host or service check is executed plugins should provide so-called
407 `performance data`. Next to that additional check performance data
408 can be fetched using Icinga 2 runtime macros such as the check latency
409 or the current service state (or additional custom attributes).
410
411 The performance data can be passed to external applications which aggregate and
412 store them in their backends. These tools usually generate graphs for historical
413 reporting and trending.
414
415 Well-known addons processing Icinga performance data are PNP4Nagios,
416 inGraph and Graphite.
417
418 ### <a id="writing-performance-data-files"></a> Writing Performance Data Files
419
420 PNP4Nagios, inGraph and Graphios use performance data collector daemons to fetch
421 the current performance files for their backend updates.
422
423 Therefore the Icinga 2 `PerfdataWriter` object allows you to define
424 the output template format for host and services backed with Icinga 2
425 runtime vars.
426
427     host_format_template = "DATATYPE::HOSTPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tHOSTPERFDATA::$host.perfdata$\tHOSTCHECKCOMMAND::$host.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$"
428     service_format_template = "DATATYPE::SERVICEPERFDATA\tTIMET::$icinga.timet$\tHOSTNAME::$host.name$\tSERVICEDESC::$service.name$\tSERVICEPERFDATA::$service.perfdata$\tSERVICECHECKCOMMAND::$service.check_command$\tHOSTSTATE::$host.state$\tHOSTSTATETYPE::$host.state_type$\tSERVICESTATE::$service.state$\tSERVICESTATETYPE::$service.state_type$"
429
430 The default templates are already provided with the Icinga 2 feature configuration
431 which can be enabled using
432
433     # icinga2 feature enable perfdata
434
435 By default all performance data files are rotated in a 15 seconds interval into
436 the `/var/spool/icinga2/perfdata/` directory as `host-perfdata.<timestamp>` and
437 `service-perfdata.<timestamp>`.
438 External collectors need to parse the rotated performance data files and then
439 remove the processed files.
440
441 ### <a id="graphite-carbon-cache-writer"></a> Graphite Carbon Cache Writer
442
443 While there are some Graphite collector scripts and daemons like Graphios available for
444 Icinga 1.x it's more reasonable to directly process the check and plugin performance
445 in memory in Icinga 2. Once there are new metrics available, Icinga 2 will directly
446 write them to the defined Graphite Carbon daemon tcp socket.
447
448 You can enable the feature using
449
450     # icinga2 feature enable graphite
451
452 By default the `GraphiteWriter` object expects the Graphite Carbon Cache to listen at
453 `127.0.0.1` on TCP port `2003`.
454
455 The current naming schema is
456
457     icinga.<hostname>.<metricname>
458     icinga.<hostname>.<servicename>.<metricname>
459
460 You can customize the metric prefix name by using the `host_name_template` and
461 `service_name_template` configuration attributes.
462
463 The example below uses [runtime macros](3-monitoring-basics.md#runtime-macros) and a
464 [global constant](19-language-reference.md#constants) named `GraphiteEnv`. The constant name
465 is freely definable and should be put in the [constants.conf](5-configuring-icinga-2.md#constants-conf) file.
466
467     const GraphiteEnv = "icinga.env1"
468
469     object GraphiteWriter "graphite" {
470       host_name_template = GraphiteEnv + ".$host.name$"
471       service_name_template = GraphiteEnv + ".$host.name$.$service.name$"
472     }
473
474 To make sure Icinga 2 writes a valid label into Graphite some characters are replaced
475 with `_` in the target name:
476
477     \/.-  (and space)
478
479 The resulting name in Graphite might look like:
480
481     www-01 / http-cert / response time
482     icinga.www_01.http_cert.response_time
483
484 In addition to the performance data retrieved from the check plugin, Icinga 2 sends
485 internal check statistic data to Graphite:
486
487   metric             | description
488   -------------------|------------------------------------------
489   current_attempt    | current check attempt
490   max_check_attempts | maximum check attempts until the hard state is reached
491   reachable          | checked object is reachable
492   downtime_depth     | number of downtimes this object is in
493   execution_time     | check execution time
494   latency            | check latency
495   state              | current state of the checked object
496   state_type         | 0=SOFT, 1=HARD state
497
498 The following example illustrates how to configure the storage-schemas for Graphite Carbon
499 Cache. Please make sure that the order is correct because the first match wins.
500
501     [icinga_internals]
502     pattern = ^icinga\..*\.(max_check_attempts|reachable|current_attempt|execution_time|latency|state|state_type)
503     retentions = 5m:7d
504
505     [icinga_default]
506     # intervals like PNP4Nagios uses them per default
507     pattern = ^icinga\.
508     retentions = 1m:2d,5m:10d,30m:90d,360m:4y
509
510 ### <a id="gelfwriter"></a> GELF Writer
511
512 The `Graylog Extended Log Format` (short: [GELF](http://www.graylog2.org/resources/gelf))
513 can be used to send application logs directly to a TCP socket.
514
515 While it has been specified by the [graylog2](http://www.graylog2.org/) project as their
516 [input resource standard](http://www.graylog2.org/resources/gelf), other tools such as
517 [Logstash](http://www.logstash.net) also support `GELF` as
518 [input type](http://logstash.net/docs/latest/inputs/gelf).
519
520 You can enable the feature using
521
522     # icinga2 feature enable gelf
523
524 By default the `GelfWriter` object expects the GELF receiver to listen at `127.0.0.1` on TCP port `12201`.
525 The default `source`  attribute is set to `icinga2`. You can customize that for your needs if required.
526
527 Currently these events are processed:
528 * Check results
529 * State changes
530 * Notifications
531
532 ### <a id="opentsdb-writer"></a> OpenTSDB Writer
533
534 While there are some OpenTSDB collector scripts and daemons like tcollector available for
535 Icinga 1.x it's more reasonable to directly process the check and plugin performance
536 in memory in Icinga 2. Once there are new metrics available, Icinga 2 will directly
537 write them to the defined TSDB TCP socket.
538
539 You can enable the feature using
540
541     # icinga2 feature enable opentsdb
542
543 By default the `OpenTsdbWriter` object expects the TSD to listen at
544 `127.0.0.1` on port `4242`.
545
546 The current naming schema is
547
548     icinga.host.<metricname>
549     icinga.service.<servicename>.<metricname>
550
551 for host and service checks. The tag host is always applied.
552
553 To make sure Icinga 2 writes a valid metric into OpenTSDB some characters are replaced
554 with `_` in the target name:
555
556     \  (and space)
557
558 The resulting name in OpenTSDB might look like:
559
560     www-01 / http-cert / response time
561     icinga.http_cert.response_time
562
563 In addition to the performance data retrieved from the check plugin, Icinga 2 sends
564 internal check statistic data to OpenTSDB:
565
566   metric             | description
567   -------------------|------------------------------------------
568   current_attempt    | current check attempt
569   max_check_attempts | maximum check attempts until the hard state is reached
570   reachable          | checked object is reachable
571   downtime_depth     | number of downtimes this object is in
572   execution_time     | check execution time
573   latency            | check latency
574   state              | current state of the checked object
575   state_type         | 0=SOFT, 1=HARD state
576
577 While reachable, state and state_type are metrics for the host or service the
578 other metrics follow the current naming schema
579
580     icinga.check.<metricname>
581
582 with the following tags
583
584   tag     | description
585   --------|------------------------------------------
586   type    | the check type, one of [host, service]
587   host    | hostname, the check ran on
588   service | the service name (if type=service)
589
590 > **Note**
591 >
592 > You might want to set the tsd.core.auto_create_metrics setting to `true`
593 > in your opentsdb.conf configuration file.
594
595
596 ## <a id="status-data"></a> Status Data
597
598 Icinga 1.x writes object configuration data and status data in a cyclic
599 interval to its `objects.cache` and `status.dat` files. Icinga 2 provides
600 the `StatusDataWriter` object which dumps all configuration objects and
601 status updates in a regular interval.
602
603     # icinga2 feature enable statusdata
604
605 Icinga 1.x Classic UI requires this data set as part of its backend.
606
607 > **Note**
608 >
609 > If you are not using any web interface or addon which uses these files
610 > you can safely disable this feature.
611
612
613 ## <a id="compat-logging"></a> Compat Logging
614
615 The Icinga 1.x log format is considered being the `Compat Log`
616 in Icinga 2 provided with the `CompatLogger` object.
617
618 These logs are not only used for informational representation in
619 external web interfaces parsing the logs, but also to generate
620 SLA reports and trends in Icinga 1.x Classic UI. Furthermore the
621 [Livestatus](15-livestatus.md#setting-up-livestatus) feature uses these logs for answering queries to
622 historical tables.
623
624 The `CompatLogger` object can be enabled with
625
626     # icinga2 feature enable compatlog
627
628 By default, the Icinga 1.x log file called `icinga.log` is located
629 in `/var/log/icinga2/compat`. Rotated log files are moved into
630 `var/log/icinga2/compat/archives`.
631
632 The format cannot be changed without breaking compatibility to
633 existing log parsers.
634
635     # tail -f /var/log/icinga2/compat/icinga.log
636
637     [1382115688] LOG ROTATION: HOURLY
638     [1382115688] LOG VERSION: 2.0
639     [1382115688] HOST STATE: CURRENT;localhost;UP;HARD;1;
640     [1382115688] SERVICE STATE: CURRENT;localhost;disk;WARNING;HARD;1;
641     [1382115688] SERVICE STATE: CURRENT;localhost;http;OK;HARD;1;
642     [1382115688] SERVICE STATE: CURRENT;localhost;load;OK;HARD;1;
643     [1382115688] SERVICE STATE: CURRENT;localhost;ping4;OK;HARD;1;
644     [1382115688] SERVICE STATE: CURRENT;localhost;ping6;OK;HARD;1;
645     [1382115688] SERVICE STATE: CURRENT;localhost;processes;WARNING;HARD;1;
646     [1382115688] SERVICE STATE: CURRENT;localhost;ssh;OK;HARD;1;
647     [1382115688] SERVICE STATE: CURRENT;localhost;users;OK;HARD;1;
648     [1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;disk;1382115705
649     [1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;http;1382115705
650     [1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;load;1382115705
651     [1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;ping4;1382115705
652     [1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;ping6;1382115705
653     [1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;processes;1382115705
654     [1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;ssh;1382115705
655     [1382115706] EXTERNAL COMMAND: SCHEDULE_FORCED_SVC_CHECK;localhost;users;1382115705
656     [1382115731] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;localhost;ping6;2;critical test|
657     [1382115731] SERVICE ALERT: localhost;ping6;CRITICAL;SOFT;2;critical test
658
659
660
661
662 ## <a id="db-ido"></a> DB IDO
663
664 The IDO (Icinga Data Output) modules for Icinga 2 take care of exporting all
665 configuration and status information into a database. The IDO database is used
666 by a number of projects including Icinga Web 1.x and 2.
667
668 Details on the installation can be found in the [Configuring DB IDO](2-getting-started.md#configuring-db-ido-mysql)
669 chapter. Details on the configuration can be found in the
670 [IdoMysqlConnection](6-object-types.md#objecttype-idomysqlconnection) and
671 [IdoPgsqlConnection](6-object-types.md#objecttype-idopgsqlconnection)
672 object configuration documentation.
673 The DB IDO feature supports [High Availability](12-distributed-monitoring-ha.md#high-availability-db-ido) in
674 the Icinga 2 cluster.
675
676 The following example query checks the health of the current Icinga 2 instance
677 writing its current status to the DB IDO backend table `icinga_programstatus`
678 every 10 seconds. By default it checks 60 seconds into the past which is a reasonable
679 amount of time - adjust it for your requirements. If the condition is not met,
680 the query returns an empty result.
681
682 > **Tip**
683 >
684 > Use [check plugins](13-addons-plugins.md#plugins) to monitor the backend.
685
686 Replace the `default` string with your instance name, if different.
687
688 Example for MySQL:
689
690     # mysql -u root -p icinga -e "SELECT status_update_time FROM icinga_programstatus ps
691       JOIN icinga_instances i ON ps.instance_id=i.instance_id
692       WHERE (UNIX_TIMESTAMP(ps.status_update_time) > UNIX_TIMESTAMP(NOW())-60)
693       AND i.instance_name='default';"
694
695     +---------------------+
696     | status_update_time  |
697     +---------------------+
698     | 2014-05-29 14:29:56 |
699     +---------------------+
700
701
702 Example for PostgreSQL:
703
704     # export PGPASSWORD=icinga; psql -U icinga -d icinga -c "SELECT ps.status_update_time FROM icinga_programstatus AS ps
705       JOIN icinga_instances AS i ON ps.instance_id=i.instance_id
706       WHERE ((SELECT extract(epoch from status_update_time) FROM icinga_programstatus) > (SELECT extract(epoch from now())-60))
707       AND i.instance_name='default'";
708
709     status_update_time
710     ------------------------
711      2014-05-29 15:11:38+02
712     (1 Zeile)
713
714
715 A detailed list on the available table attributes can be found in the [DB IDO Schema documentation](22-appendix.md#schema-db-ido).
716
717
718 ## <a id="check-result-files"></a> Check Result Files
719
720 Icinga 1.x writes its check result files to a temporary spool directory
721 where they are processed in a regular interval.
722 While this is extremely inefficient in performance regards it has been
723 rendered useful for passing passive check results directly into Icinga 1.x
724 skipping the external command pipe.
725
726 Several clustered/distributed environments and check-aggregation addons
727 use that method. In order to support step-by-step migration of these
728 environments, Icinga 2 supports the `CheckResultReader` object.
729
730 There is no feature configuration available, but it must be defined
731 on-demand in your Icinga 2 objects configuration.
732
733     object CheckResultReader "reader" {
734       spool_dir = "/data/check-results"
735     }