Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. for score_file in `ls /proc/*/oom_score 2>/dev/null`;
  4. do
  5. score=$(cat $score_file 2>/dev/null);
  6.  
  7. if [[ x$score != 'x' ]]; then
  8. if [[ $score > 100 ]]; then
  9. pid=$(echo $score_file 2>/dev/null | awk -F'/' '{print $3}')
  10. if [[ x$pid != 'x' ]]; then
  11. cmdline=$(cat /proc/$pid/cmdline 2>/dev/null | tr '\000' ' ')
  12. if [[ x$cmdline != 'x' ]]; then
  13. echo $pid, $score, $cmdline >> /tmp/cmdline
  14. fi
  15. fi
  16. fi
  17. fi
  18. done
  19.  
  20. # 怎么用呢?
  21. # 排序目前 oom score 最大的 pid,也就是被 oom-killer 风险最大的进程:cat /tmp/cmdline | sort -rnk2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement