Code Monkey home page Code Monkey logo

oom-killer-score's Introduction

OOM-Killer

Here are 2 scripts designed to asses the systems processes and their oom_score.
The oom score will dictate which process is most likely to be killed next by the kernel when oom-killer is invoked (due to low memory (ram))

Safest way to run the script:
git clone https://github.com/LukeShirnia/OOM-Killer-score.git
cd OOM-Killer-score
python score_check.py

To run script: Note: the python script runs faster than the bash script.
curl -s https://raw.githubusercontent.com/LukeShirnia/OOM-Killer-score/master/score_check.sh | bash
curl -s https://raw.githubusercontent.com/LukeShirnia/OOM-Killer-score/master/score_check.py | python

Or you can use the following bash one-liner (but again, python is quicker):

for i in $(find /proc -maxdepth 1 -type d); do if [ -f "$i"/oom_score ]; then printf "$(cat "$i"/oom_score) "; pid=$(echo "$i" | awk -F'/' '{print $3}';); if [ "$(cat "$i"/oom_score)" -ge 1 ];then printf "$(ps -p "$pid" -o comm=) "; fi; printf "$i/oom_score \n"; fi; done | awk '$1 > 1' | sort -nr -k1

Example output:

121 mysqld /proc/24828/oom_score
103 rackspace-monit /proc/15168/oom_score 
94 varnishd /proc/13528/oom_score 
84 varnishd /proc/13527/oom_score 
45 php-fpm /proc/25685/oom_score 
44 php-fpm /proc/25686/oom_score 
42 php-fpm /proc/6820/oom_score 
42 php-fpm /proc/25687/oom_score 
41 php-fpm /proc/25684/oom_score 
40 php-fpm /proc/25683/oom_score 
39 php-fpm /proc/26555/oom_score 
36 php-fpm /proc/2879/oom_score 
36 php-fpm /proc/2868/oom_score 
19 php-fpm /proc/25681/oom_score 
17 firewalld /proc/529/oom_score 
16 driveclient /proc/21200/oom_score 
13 python /proc/10338/oom_score 
10 tuned /proc/871/oom_score 
9 polkitd /proc/4899/oom_score 
8 fail2ban-server /proc/13549/oom_score 
6 php-fpm /proc/25692/oom_score 
6 php-fpm /proc/25691/oom_score 
6 php-fpm /proc/25690/oom_score 
6 php-fpm /proc/25689/oom_score 
6 php-fpm /proc/25688/oom_score

oom-killer-score's People

Contributors

lukeshirnia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

oom-killer-score's Issues

Not and issue just a comment

Found this pretty nice so i added it to c7repos as a function called 'checkOOM'. It's basically the same as what you wrote except i added escapes to each of the different commands since i deal with a huge amount of hosts and some commands are aliased to very specific stuff in some places. Anyways, figured you'd like to know.

cool thing. thanks

I have given proper credits i believe.

Please close this ๐Ÿ‘

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.