]> granicus.if.org Git - icinga2/blob - doc/15-troubleshooting.md
Implement comparison operators for the Array class
[icinga2] / doc / 15-troubleshooting.md
1 # <a id="troubleshooting"></a> Icinga 2 Troubleshooting
2
3 ## <a id="troubleshooting-information-required"></a> Which information is required
4
5 * Run `icinga2 troubleshoot` to collect required troubleshooting information
6 * Alternative, manual steps:
7         * `icinga2 --version`
8         * `icinga2 feature list`
9         * `icinga2 daemon --validate`
10         * Relevant output from your main and debug log ( `icinga2 object list --type='filelogger'` )
11         * The newest Icinga 2 crash log if relevant
12         * Your icinga2.conf and, if you run multiple Icinga 2 instances, your zones.conf
13 * How was Icinga 2 installed (and which repository in case) and which distribution are you using
14 * Provide complete configuration snippets explaining your problem in detail
15 * If the check command failed, what's the output of your manual plugin tests?
16 * In case of [debugging](20-development.md#development) Icinga 2, the full back traces and outputs
17
18 ## <a id="troubleshooting-enable-debug-output"></a> Enable Debug Output
19
20 Enable the `debuglog` feature:
21
22     # icinga2 feature enable debuglog
23     # service icinga2 restart
24
25 You can find the debug log file in `/var/log/icinga2/debug.log`.
26
27 Alternatively you may run Icinga 2 in the foreground with debugging enabled. Specify the console
28 log severity as an additional parameter argument to `-x`.
29
30     # /usr/sbin/icinga2 daemon -x notice
31
32 The log level can be one of `critical`, `warning`, `information`, `notice`
33 and `debug`.
34
35 ## <a id="list-configuration-objects"></a> List Configuration Objects
36
37 The `icinga2 object list` CLI command can be used to list all configuration objects and their
38 attributes. The tool also shows where each of the attributes was modified.
39
40 > **Tip**
41 >
42 > Use the Icinga 2 API to access [config objects at runtime](12-icinga2-api.md#icinga2-api-config-objects) directly.
43
44 That way you can also identify which objects have been created from your [apply rules](17-language-reference.md#apply).
45
46     # icinga2 object list
47
48     Object 'localhost!ssh' of type 'Service':
49       * __name = 'localhost!ssh'
50       * check_command = 'ssh'
51         % = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 5:3-5:23
52       * check_interval = 60
53         % = modified in '/etc/icinga2/conf.d/templates.conf', lines 24:3-24:21
54       * host_name = 'localhost'
55         % = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 4:3-4:25
56       * max_check_attempts = 3
57         % = modified in '/etc/icinga2/conf.d/templates.conf', lines 23:3-23:24
58       * name = 'ssh'
59       * retry_interval = 30
60         % = modified in '/etc/icinga2/conf.d/templates.conf', lines 25:3-25:22
61       * templates = [ 'ssh', 'generic-service' ]
62         % += modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 1:0-7:1
63         % += modified in '/etc/icinga2/conf.d/templates.conf', lines 22:1-26:1
64       * type = 'Service'
65       * vars
66         % += modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 6:3-6:19
67         * sla = '24x7'
68           % = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 6:3-6:19
69
70     [...]
71
72 You can also filter by name and type:
73
74     # icinga2 object list --name *ssh* --type Service
75     Object 'localhost!ssh' of type 'Service':
76       * __name = 'localhost!ssh'
77       * check_command = 'ssh'
78         % = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 5:3-5:23
79       * check_interval = 60
80         % = modified in '/etc/icinga2/conf.d/templates.conf', lines 24:3-24:21
81       * host_name = 'localhost'
82         % = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 4:3-4:25
83       * max_check_attempts = 3
84         % = modified in '/etc/icinga2/conf.d/templates.conf', lines 23:3-23:24
85       * name = 'ssh'
86       * retry_interval = 30
87         % = modified in '/etc/icinga2/conf.d/templates.conf', lines 25:3-25:22
88       * templates = [ 'ssh', 'generic-service' ]
89         % += modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 1:0-7:1
90         % += modified in '/etc/icinga2/conf.d/templates.conf', lines 22:1-26:1
91       * type = 'Service'
92       * vars
93         % += modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 6:3-6:19
94         * sla = '24x7'
95           % = modified in '/etc/icinga2/conf.d/hosts/localhost/ssh.conf', lines 6:3-6:19
96
97     Found 1 Service objects.
98
99     [2014-10-15 14:27:19 +0200] information/cli: Parsed 175 objects.
100
101 ## <a id="check-command-definitions"></a> Where are the check command definitions?
102
103 Icinga 2 features a number of built-in [check command definitions](10-icinga-template-library.md#plugin-check-commands) which are
104 included using
105
106     include <itl>
107     include <plugins>
108
109 in the [icinga2.conf](4-configuring-icinga-2.md#icinga2-conf) configuration file. These files are not considered configuration files and will be overridden
110 on upgrade, so please send modifications as proposed patches upstream. The default include path is set to
111 `LocalStateDir + "/share/icinga2/includes"`.
112
113 You should add your own command definitions to a new file in `conf.d/` called `commands.conf`
114 or similar.
115
116 ## <a id="troubleshooting-checks"></a> Checks
117
118 ### <a id="checks-executed-command"></a> Executed Command for Checks
119
120 * Use the Icinga 2 API to [query](12-icinga2-api.md#icinga2-api-config-objects-query) host/service objects
121 for their check result containing the executed shell command.
122 * Use the Icinga 2 [console cli command](11-cli-commands.md#cli-command-console)
123 to fetch the checkable object, its check result and the executed shell command.
124 * Alternatively enable the [debug log](15-troubleshooting.md#troubleshooting-enable-debug-output) and look for the executed command.
125
126 ### <a id="checks-not-executed"></a> Checks are not executed
127
128 * Check the [debug log](15-troubleshooting.md#troubleshooting-enable-debug-output) to see if the check command gets executed.
129 * Verify that failed depedencies do not prevent command execution.
130 * Make sure that the plugin is executable by the Icinga 2 user (run a manual test).
131 * Make sure the [checker](11-cli-commands.md#enable-features) feature is enabled.
132 * Use the Icinga 2 API [event streams](12-icinga2-api.md#icinga2-api-event-streams) to receive live check result streams.
133
134 Examples:
135
136     # sudo -u icinga /usr/lib/nagios/plugins/check_ping -4 -H 127.0.0.1 -c 5000,100% -w 3000,80%
137
138     # icinga2 feature enable checker
139     The feature 'checker' is already enabled.
140
141 Fetch all check result events matching the `event.service` name `random`:
142
143     $ curl -k -s -u root:icinga -X POST 'https://localhost:5665/v1/events?queue=debugchecks&types=CheckResult&filter=match%28%22random*%22,event.service%29'
144
145
146 ## <a id="notifications-not-sent"></a> Notifications are not sent
147
148 * Check the debug log to see if a notification is triggered.
149 * If yes, verify that all conditions are satisfied.
150 * Are any errors on the notification command execution logged?
151
152 Verify the following configuration:
153
154 * Is the host/service `enable_notifications` attribute set, and if so, to which value?
155 * Do the notification attributes `states`, `types`, `period` match the notification conditions?
156 * Do the user attributes `states`, `types`, `period` match the notification conditions?
157 * Are there any notification `begin` and `end` times configured?
158 * Make sure the [notification](11-cli-commands.md#enable-features) feature is enabled.
159 * Does the referenced NotificationCommand work when executed as Icinga user on the shell?
160
161 If notifications are to be sent via mail, make sure that the mail program specified inside the
162 [NotificationCommand object](9-object-types.md#objecttype-notificationcommand) exists.
163 The name and location depends on the distribution so the preconfigured setting might have to be
164 changed on your system.
165
166
167 Examples:
168
169     # icinga2 feature enable notification
170     The feature 'notification' is already enabled.
171
172 You can use the Icinga 2 API [event streams](12-icinga2-api.md#icinga2-api-event-streams) to receive live notification streams:
173
174     $ curl -k -s -u root:icinga -X POST 'https://localhost:5665/v1/events?queue=debugnotifications&types=Notification'
175
176
177 ## <a id="feature-not-working"></a> Feature is not working
178
179 * Make sure that the feature configuration is enabled by symlinking from `features-available/`
180 to `features-enabled` and that the latter is included in [icinga2.conf](4-configuring-icinga-2.md#icinga2-conf).
181 * Are the feature attributes set correctly according to the documentation?
182 * Any errors on the logs?
183
184 ## <a id="configuration-ignored"></a> Configuration is ignored
185
186 * Make sure that the line(s) are not [commented out](17-language-reference.md#comments) (starting with `//` or `#`, or
187 encapsulated by `/* ... */`).
188 * Is the configuration file included in [icinga2.conf](4-configuring-icinga-2.md#icinga2-conf)?
189
190 ## <a id="configuration-attribute-inheritance"></a> Configuration attributes are inherited from
191
192 Icinga 2 allows you to import templates using the [import](17-language-reference.md#template-imports) keyword. If these templates
193 contain additional attributes, your objects will automatically inherit them. You can override
194 or modify these attributes in the current object.
195
196 ## <a id="configuration-value-dollar-sign"></a> Configuration Value with Single Dollar Sign
197
198 In case your configuration validation fails with a missing closing dollar sign error message, you
199 did not properly escape the single dollar sign preventing its usage as [runtime macro](3-monitoring-basics.md#runtime-macros).
200
201     critical/config: Error: Validation failed for Object 'ping4' (Type: 'Service') at /etc/icinga2/zones.d/global-templates/windows.conf:24: Closing $ not found in macro format string 'top-syntax=${list}'.
202
203
204 ## <a id="troubleshooting-cluster"></a> Cluster and Clients Troubleshooting
205
206 This applies to any Icinga 2 node in a [distributed monitoring setup](6-distributed-monitoring.md#distributed-monitoring-scenarios).
207
208 You should configure the [cluster health checks](6-distributed-monitoring.md#distributed-monitoring-health-checks) if you haven't
209 done so already.
210
211 > **Note**
212 >
213 > Some problems just exist due to wrong file permissions or packet filters applied. Make
214 > sure to check these in the first place.
215
216 ### <a id="troubleshooting-cluster-connection-errors"></a> Cluster Troubleshooting Connection Errors
217
218 General connection errors normally lead you to one of the following problems:
219
220 * Wrong network configuration
221 * Packet loss on the connection
222 * Firewall rules preventing traffic
223
224 Use tools like `netstat`, `tcpdump`, `nmap`, etc. to make sure that the cluster communication
225 happens (default port is `5665`).
226
227     # tcpdump -n port 5665 -i any
228
229     # netstat -tulpen | grep icinga
230
231     # nmap yourclusternode.localdomain
232
233 ### <a id="troubleshooting-cluster-ssl-errors"></a> Cluster Troubleshooting SSL Errors
234
235 If the cluster communication fails with SSL error messages, make sure to check
236 the following
237
238 * File permissions on the SSL certificate files
239 * Does the used CA match for all cluster endpoints?
240   * Verify the `Issuer` being your trusted CA
241   * Verify the `Subject` containing your endpoint's common name (CN)
242   * Check the validity of the certificate itself
243
244 Steps on the client `icinga2-node2.localdomain`:
245
246     # ls -la /etc/icinga2/pki
247
248     # cd /etc/icinga2/pki/
249     # openssl x509 -in icinga2-node2.localdomain.crt -text
250     Certificate:
251         Data:
252             Version: 1 (0x0)
253             Serial Number: 2 (0x2)
254         Signature Algorithm: sha1WithRSAEncryption
255             Issuer: C=DE, ST=Bavaria, L=Nuremberg, O=NETWAYS GmbH, OU=Monitoring, CN=Icinga CA
256             Validity
257                 Not Before: Jan  7 13:17:38 2014 GMT
258                 Not After : Jan  5 13:17:38 2024 GMT
259             Subject: C=DE, ST=Bavaria, L=Nuremberg, O=NETWAYS GmbH, OU=Monitoring, CN=icinga2-node2.localdomain
260             Subject Public Key Info:
261                 Public Key Algorithm: rsaEncryption
262                     Public-Key: (4096 bit)
263                     Modulus:
264                     ...
265
266 Try to manually connect from `icinga2-node2.localdomain` to the master node `icinga2-node1.localdomain`:
267
268     # openssl s_client -CAfile /etc/icinga2/pki/ca.crt -cert /etc/icinga2/pki/icinga2-node2.localdomain.crt -key /etc/icinga2/pki/icinga2-node2.localdomain.key -connect icinga2-node1.localdomain:5665
269
270     CONNECTED(00000003)
271     ---
272     ...
273
274 If the connection attempt fails or your CA does not match, [verify the master and client certificates](15-troubleshooting.md#troubleshooting-cluster-ssl-certificate-verification).
275
276 #### <a id="troubleshooting-cluster-unauthenticated-clients"></a> Cluster Troubleshooting Unauthenticated Clients
277
278 Unauthenticated nodes are able to connect. This is required for client setups.
279
280 Master:
281
282     [2015-07-13 18:29:25 +0200] information/ApiListener: New client connection for identity 'icinga-client' (unauthenticated)
283
284 Client as command execution bridge:
285
286     [2015-07-13 18:29:26 +1000] notice/ApiEvents: Discarding 'execute command' message from 'icinga-master': Invalid endpoint origin (client not allowed).
287
288 If these messages do not go away, make sure to [verify the master and client certificates](15-troubleshooting.md#troubleshooting-cluster-ssl-certificate-verification).
289
290 #### <a id="troubleshooting-cluster-ssl-certificate-verification"></a> Cluster Troubleshooting SSL Certificate Verification
291
292 Make sure to verify the client's certificate and its received `ca.crt` in `/etc/icinga2/pki` and ensure that
293 both instances are signed by the **same CA**.
294
295     # openssl verify -verbose -CAfile /etc/icinga2/pki/ca.crt /etc/icinga2/pki/icinga2-node1.localdomain.crt
296     icinga2-node1.localdomain.crt: OK
297
298     # openssl verify -verbose -CAfile /etc/icinga2/pki/ca.crt /etc/icinga2/pki/icinga2-node2.localdomain.crt
299     icinga2-node2.localdomain.crt: OK
300
301 Fetch the `ca.crt` file from the client node and compare it to your master's `ca.crt` file:
302
303     # scp icinga2-node2:/etc/icinga2/pki/ca.crt test-client-ca.crt
304     # diff -ur /etc/icinga2/pki/ca.crt test-client-ca.crt
305
306 On SLES11 you'll need to use the `openssl1` command instead of `openssl`.
307
308 ### <a id="troubleshooting-cluster-message-errors"></a> Cluster Troubleshooting Message Errors
309
310 At some point, when the network connection is broken or gone, the Icinga 2 instances
311 will be disconnected. If the connection can't be re-established between endpoints in the same HA zone,
312 they remain in a Split-Brain-mode and history may differ.
313
314 Although the Icinga 2 cluster protocol stores historical events in a [replay log](15-troubleshooting.md#troubleshooting-cluster-replay-log)
315 for later synchronisation, you should make sure to check why the network connection failed.
316
317 ### <a id="troubleshooting-cluster-command-endpoint-errors"></a> Cluster Troubleshooting Command Endpoint Errors
318
319 Command endpoints can be used [for clients](6-distributed-monitoring.md#distributed-monitoring-top-down-command-endpoint)
320 as well as inside an [High-Availability cluster](6-distributed-monitoring.md#distributed-monitoring-scenarios).
321
322 There is no cli command for manually executing the check, but you can verify
323 the following (e.g. by invoking a forced check from the web interface):
324
325 * `/var/log/icinga2/icinga2.log` contains connection and execution errors.
326  * The ApiListener is not enabled to [accept commands](6-distributed-monitoring.md#distributed-monitoring-top-down-command-endpoint).
327  * `CheckCommand` definition not found on the remote client.
328  * Referenced check plugin not found on the remote client.
329  * Runtime warnings and errors, e.g. unresolved runtime macros or configuration problems.
330 * Specific error messages are also populated into `UNKNOWN` check results including a detailed error message in their output.
331 * Verify the `check_source` object attribute. This is populated by the node executing the check.
332 * More verbose logs are found inside the [debug log](15-troubleshooting.md#troubleshooting-enable-debug-output).
333
334 * Use the Icinga 2 API [event streams](12-icinga2-api.md#icinga2-api-event-streams) to receive live check result streams.
335
336 Fetch all check result events matching the `event.service` name `remote-client`:
337
338     $ curl -k -s -u root:icinga -X POST 'https://localhost:5665/v1/events?queue=debugcommandendpoint&types=CheckResult&filter=match%28%22remote-client*%22,event.service%29'
339
340
341
342 ### <a id="troubleshooting-cluster-config-sync"></a> Cluster Troubleshooting Config Sync
343
344 If the cluster zones do not sync their configuration, make sure to check the following:
345
346 * Within a config master zone, only one configuration master is allowed to have its config in `/etc/icinga2/zones.d`.
347 ** The master syncs the configuration to `/var/lib/icinga2/api/zones/` during startup and only syncs valid configuration to the other nodes.
348 ** The other nodes receive the configuration into `/var/lib/icinga2/api/zones/`.
349 * The `icinga2.log` log file in `/var/log/icinga2` will indicate whether this ApiListener
350 [accepts config](6-distributed-monitoring.md#distributed-monitoring-top-down-config-sync), or not.
351
352 Verify the object's [version](9-object-types.md#object-types) attribute on all nodes to
353 check whether the config update and reload was succesful or not.
354
355 ### <a id="troubleshooting-cluster-check-results"></a> Cluster Troubleshooting Overdue Check Results
356
357 If your master does not receive check results (or any other events) from the child zones
358 (satellite, clients, etc.), make sure to check whether the client sending in events
359 is allowed to do so.
360
361 The [distributed monitoring conventions](6-distributed-monitoring.md#distributed-monitoring-conventions)
362 apply. So, if there's a mismatch between your client node's endpoint name and its provided
363 certificate's CN, the master will deny all events.
364
365 > **Tip**
366 >
367 > [Icinga Web 2](2-getting-started.md#setting-up-icingaweb2) provides a dashboard view
368 > for overdue check results.
369
370 Enable the [debug log](15-troubleshooting.md#troubleshooting-enable-debug-output) on the master
371 for more verbose insights.
372
373 If the client cannot authenticate, it's a more general [problem](15-troubleshooting.md#troubleshooting-cluster-unauthenticated-clients).
374
375 The client's endpoint is not configured on nor trusted by the master node:
376
377     Discarding 'check result' message from 'icinga2b': Invalid endpoint origin (client not allowed).
378
379 The check result message sent by the client does not belong to the zone the checkable object is
380 in on the master:
381
382     Discarding 'check result' message from 'icinga2b': Unauthorized access.
383
384
385 ### <a id="troubleshooting-cluster-replay-log"></a> Cluster Troubleshooting Replay Log
386
387 If your `/var/lib/icinga2/api/log` directory grows, it generally means that your cluster
388 cannot replay the log on connection loss and re-establishment. A master node for example
389 will store all events for not connected endpoints in the same and child zones.
390
391 Check the following:
392
393 * All clients are connected? (e.g. [cluster health check](6-distributed-monitoring.md#distributed-monitoring-health-checks)).
394 * Check your [connection](15-troubleshooting.md#troubleshooting-cluster-connection-errors) in general.
395 * Does the log replay work, e.g. are all events processed and the directory gets cleared up over time?
396 * Decrease the `log_duration` attribute value for that specific [endpoint](9-object-types.md#objecttype-endpoint).