Last active
February 16, 2024 11:22
-
-
Save Flova/94d07fbde37d033b4ee19af55d60a23a to your computer and use it in GitHub Desktop.
Creates a memory dump of a running nginx. Usefull for getting lost config files from a running machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the process id of nginx | |
NGINX_PID=$(pgrep -o 'nginx') | |
echo Nginx server PID: $NGINX_PID | |
# Get the memory parts that are used by nginx. | |
# That make gdb dump commands with it and dump the corresponding memory into files | |
cat /proc/$NGINX_PID/maps \ | |
| awk ' | |
$6 !~ "^/" {split ($1,address,"-"); | |
print "dump memory mem_" address[1] " 0x" address[1] " 0x" address[2] ;} | |
END{print "quit"}' \ | |
| tee /tmp/gdb_cmds | |
# Run gdb to dump the memory | |
gdb -p $NGINX_PID -x /tmp/gdb_cmds |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment