From bdad32ce8737ca2ff054b6c83fcbe1e2aa2b1724 Mon Sep 17 00:00:00 2001 From: Julien Dessaux Date: Tue, 5 Oct 2021 19:54:19 +0200 Subject: Added oom blog article --- content/blog/miscellaneous/investigating-oom.md | 35 +++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 content/blog/miscellaneous/investigating-oom.md (limited to 'content/blog/miscellaneous') diff --git a/content/blog/miscellaneous/investigating-oom.md b/content/blog/miscellaneous/investigating-oom.md new file mode 100644 index 0000000..3e1223d --- /dev/null +++ b/content/blog/miscellaneous/investigating-oom.md @@ -0,0 +1,35 @@ +--- +title: How to list oom killer score of running linux processus +description: a shell command that could be a one liner +date: 2021-10-05 +tags: +- linux +- toolbox +--- + +## Introduction + +There seems to be a missing piece for investigating what the oom killer will do when a linux kernel will run out of memory. Since oom_scores can be adjusted, looking at memory consumption is not enough to get a clear picture. + +## The command + +The base of the command came from a colleague, I refined it with the sort and tail : +```sh +while read -r pid comm; do + printf '%d\t%d\t%s\n' "$pid" "$(cat /proc/$pid/oom_score)" "$comm" +done < <(ps -e -o pid= -o comm=)|sort -n -k2|tail +``` + +On a busy server, the output will look like : +``` +306 2 systemd-journal +673 2 haproxy +616 6 puppet +8370 7 mcollectived +1728 8 varnishncsa +14652 9 php-fpm7.2 +14668 10 php-fpm7.2 +14653 13 php-fpm7.2 +1415 186 cache-main +29124 313 mysqld +``` -- cgit v1.2.3