{"id":1706,"date":"2024-05-03T11:41:40","date_gmt":"2024-05-03T03:41:40","guid":{"rendered":"https:\/\/www.strongd.net\/?p=1706"},"modified":"2024-05-03T11:41:40","modified_gmt":"2024-05-03T03:41:40","slug":"dump-nginx-memory","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=1706","title":{"rendered":"dump nginx memory"},"content":{"rendered":"<pre><code># Set pid of nginx master process here\r\npid=8192\r\n\r\n# generate gdb commands from the process's memory mappings using awk\r\ncat \/proc\/$pid\/maps | awk '$6 !~ \"^\/\" {split ($1,addrs,\"-\"); print \"dump memory mem_\" addrs[1] \" 0x\" addrs[1] \" 0x\" addrs[2] ;}END{print \"quit\"}' &gt; gdb-commands\r\n\r\n# use gdb with the -x option to dump these memory regions to mem_* files\r\ngdb -p $pid -x gdb-commands\r\n\r\n# look for some (any) nginx.conf text\r\ngrep worker_connections mem_*\r\ngrep server_name mem_*\r\n<\/code><\/pre>\n<p>You should get something like &#8220;Binary file mem_086cb000 matches&#8221;. Open this file in editor, search for config (e.g. &#8220;worker_connections&#8221; directive), copy&amp;paste. Profit!<\/p>\n<p>Update: This method isn&#8217;t entirely reliable. It&#8217;s based on assumption that nginx process will read configuration and don&#8217;t overwrite\/reuse this memory area later. Master nginx process gives us best chances for that I guess.<\/p>\n","protected":false},"excerpt":{"rendered":"<p># Set pid of nginx master process here pid=8192 # generate gdb commands from the process&#8217;s memory mappings using awk cat \/proc\/$pid\/maps | awk &#8216;$6 !~ &#8220;^\/&#8221; {split ($1,addrs,&#8221;-&#8220;); print &#8220;dump memory mem_&#8221; addrs[1] &#8221; 0x&#8221; addrs[1] &#8221; 0x&#8221; addrs[2] ;}END{print &#8220;quit&#8221;}&#8217; &gt; gdb-commands # use gdb with the -x option to dump these memory &hellip; <a href=\"https:\/\/www.strongd.net\/?p=1706\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">dump nginx memory<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1706","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1706","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1706"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1706\/revisions"}],"predecessor-version":[{"id":1707,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/1706\/revisions\/1707"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1706"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1706"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1706"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}