How do I run commands using kdump, before or after a vmcore is saved?
Environment
- Red Hat Enterprise Linux (RHEL)
- kexec-tools
Issue
- How do I run commands using kdump, before or after a vmcore is saved?
- Can a script be run that can determines the outcome which kdump target to use?
Resolution
The kdump_pre and kdump_post options that come with kdump, can be used to run commands before or after the vmcore file is saved. Additionally, the program/script attaches as kdump_post also receives the return value from vmcore collection as it's first argument.
The following steps describe an example for the kdump_pre option:
- Create a script file and add following contents:
#!/bin/sh
echo "### Running kdump_pre ###"
exit $?
- Make the script file executable
- Edit /etc/kdump.conf and add following:
kdump_pre /path/to/script_file
- Restart the kdump service. This will create a new kdump initrd file:
# service kdump restart
Now the kdump-initrd file will contain the script file and it will be run prior to saving the vmcore when a panic occurs.
Root Cause
- The
kdump_preandkdump_postoptions in the /etc/kdump.conf file advise kdump to include a particular script or program in the kdump initrd file, and to run it before or after dumping the vmcore.
Diagnostic Steps
This solution may apply if you need to run a particular script prior to or after saving the vmcore after a kernel panic has occurred and the kdump kernel has been invoked.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.