You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most distributions offer systemd's coredumpctl either by default or as a package. Distributions that offer it by default include RHEL and SLES, on others like Debian or Ubuntu it can be installed via the `systemd-coredump` package. When set up correctly, `core_pattern` will look something like this:
You can look at the generated core dumps with the `coredumpctl list` command. You can show information, including a stack-trace using `coredumpctl show icinga2 -1` and retrieve the actual core-dump file with `coredumpctl dump icinga2 -1 --output <file>`.
Apport is unsuitable for development work, because by default it only works with Ubuntu packages and it has a rather complicated interface for retrieving the core dump.
294
298
299
+
To set it up to work with unpackaged programs, add the following (create the file if it doesn't exist) to `/etc/apport/settings`:
295
300
```
296
-
vim /etc/init.d/icinga2
297
-
...
298
-
ulimit -c unlimited
299
-
300
-
service icinga2 restart
301
+
[main]
302
+
unpackaged=true
301
303
```
302
-
303
-
##### Verify
304
-
305
-
Verify that the Icinga 2 process core file size limit is set to `unlimited`.
306
-
304
+
and restart Apport:
307
305
```
308
-
for pid in $(pidof icinga2); do cat /proc/$pid/limits; done
309
-
310
-
...
311
-
Max core file size unlimited unlimited bytes
306
+
systemctl restart apport.service
312
307
```
313
308
309
+
When the program crashes you can then find an Apport crash report in `/var/crash/` that you can read with the interactive `apport-cli` command. To extract the core dump you run `apport-unpack /var/crash/<crash-file> <output-dir>` which then saves a `<outputdir>/CoreDump` file that contains the actual core dump.
310
+
311
+
Unless you rely on Apport for some other workflow, systemd's coredumpctl is a much better option and is available on Ubuntu in the `systemd-coredump` package that can replace Apport on your system with no further setup required.
314
312
315
-
#### Core Dump Kernel Format <aid="development-debug-core-dump-format"></a>
313
+
#### Directly to a File <aid="development-debug-core-dump-direct"></a>
316
314
317
-
The Icinga 2 daemon runs with the SUID bit set. Therefore you need
318
-
to explicitly enable core dumps for SUID on Linux.
315
+
If coredumpctl is not available, simply writing the core dump directly to a file is also sufficient. You can set up your `core_pattern` to write a file to a suitable path:
Adjust the coredump kernel format and file location on Linux:
322
+
This will create core dump files in `/tmp/cores` where `%e` is the truncated name of the program, `%p` is the programs PID, `%h` is the hostname, and `%t` a timestamp.
323
+
324
+
Note that unlike the other methods this requires the core size limit to be set for the process. When starting Icinga 2 via systemd you can set it to unlimited by adding the following to `/etc/systemd/system/icinga2.service.d/limits.conf`:
325
+
```
326
+
[Service]
327
+
LimitCORE=infinity
328
+
```
325
329
330
+
When using an init script or starting manually you need to run `ulimit -c unlimited` before starting the program:
0 commit comments