Created
October 31, 2014 10:14
-
-
Save rubenruizdegauna/bf8161a5b664ca85636d to your computer and use it in GitHub Desktop.
Prints all the processes (swap amount, pid and name w/o params) that are using swap ordered by swap amount
This file contains 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
#!/usr/bin/env bash | |
# Prints all the processes that are using swap ordered by swap amount (DESC) | |
for PID in $( ls /proc/|egrep "^[0-9]" );do | |
PROCNAME=$( ps -e -o pid,comm|grep ${PID}|awk '{print $2}' ) | |
awk -v PID=${PID} -v PROCNAME=${PROCNAME} '/Swap/{sum+=$2}END{print (sum/1024)"\t"PID"\t"PROCNAME}' /proc/${PID}/smaps 2>/dev/null |egrep -v "^0" | |
done | sort -nr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment