Created
July 15, 2015 12:00
-
-
Save tvlooy/7485a958fb73720f5035 to your computer and use it in GitHub Desktop.
Find swap users
This file contains hidden or 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
| #!/bin/bash | |
| TOTAL=0 | |
| for i in `find /proc -maxdepth 2 -type f -name status`; do | |
| PID=`echo $i | cut -d/ -f3` | |
| SWAP=$(grep VmSwap /proc/$PID/status 2>/dev/null | cut -d: -f2 | xargs | grep -v '^0 kB$') | |
| if [ -n "$SWAP" ]; then | |
| echo "$PID (`ps -p $PID -o comm=`) = $SWAP" | |
| let TOTAL=$TOTAL+`echo $SWAP | cut -d' ' -f1` | |
| fi | |
| done | |
| echo total $TOTAL kB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment