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
303
+
```
304
+
and restart Apport:
305
+
```
306
+
systemctl restart apport.service
301
307
```
302
308
303
-
##### Verify
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.
304
310
305
-
Verify that the Icinga 2 process core file size limit is set to `unlimited`.
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.
306
312
307
-
```
308
-
for pid in $(pidof icinga2); do cat /proc/$pid/limits; done
313
+
#### Directly to a File <aid="development-debug-core-dump-direct"></a>
309
314
310
-
...
311
-
Max core file size unlimited unlimited bytes
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:
#### Core Dump Kernel Format <aid="development-debug-core-dump-format"></a>
327
+
This will create core dump files in `/var/lib/cores` where `%e` is the truncated name of the program, `%p` is the programs PID, `%h` is the hostname, and `%t` a timestamp.
316
328
317
-
The Icinga 2 daemon runs with the SUID bit set. Therefore you need
318
-
to explicitly enable core dumps for SUID on Linux.
329
+
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`:
330
+
```
331
+
[Service]
332
+
LimitCORE=infinity
333
+
```
319
334
335
+
When using an init script or starting manually you need to run `ulimit -c unlimited` before starting the program:
320
336
```bash
321
-
sysctl -w fs.suid_dumpable=2
337
+
ulimit -c unlimited
338
+
./icinga2 daemon
322
339
```
323
340
324
-
Adjust the coredump kernel format and file location on Linux:
325
-
341
+
To verify that the limit has been set to `unlimited` run the following:
0 commit comments