Skip to content

Instantly share code, notes, and snippets.

@dubcl
Created July 2, 2020 20:02
Show Gist options
  • Save dubcl/2bc1ec5045d26b13614b9afce494ffc9 to your computer and use it in GitHub Desktop.
Save dubcl/2bc1ec5045d26b13614b9afce494ffc9 to your computer and use it in GitHub Desktop.
Show swap apps
function showswap() {
find /proc -maxdepth 2 -path "/proc/[0-9]*/status" -readable -exec awk -v FS=":" '{process[$1]=$2;sub(/^[ \t]+/,"",process[$1]);} END {if(process["VmSwap"] && process["VmSwap"] != "0 kB") printf "%10s %-30s %20s\n",process["Pid"],process["Name"],process["VmSwap"]}' '{}' \; | awk '{print $(NF-1),$0}' | sort -h | cut -d " " -f2-
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment