processes are swapping list
#!/bin/bash
# Pipe the output to "sort -nk3" to get sorted output
SUM=0
OVERALL=0
for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+"`
do
PID=`echo $DIR | cut -d / -f 3`
PROGNAME=`ps -p $PID -o comm --no-headers`
for SWAP in `grep Swap $DIR/smaps 2>/dev/null | awk '{ print $2 }'`
do
let SUM=$SUM+$SWAP
done
if (( $SUM > 0 )); then
#echo "PID=$PID swapped $SUM KB ($PROGNAME)"
#human_readable="$(( ${SUM} / 1024))"
human_readable=$(echo "$SUM / 1024"|bc -l )
echo "PID=$PID swapped $human_readable MB ($PROGNAME)"
fi
let OVERALL=$OVERALL+$SUM
SUM=0
done
echo "Overall swap used: $OVERALL KB"
# bash swap_usage_finder.sh |sort -nrk3
#PID=24580 swapped 4770.19531250000000000000 MB (mysqld)
#PID=24737 swapped 211.56250000000000000000 MB (java)
#PID=28295 swapped 143.37109375000000000000 MB (java)
#PID=2170 swapped 88.58984375000000000000 MB (python)
#PID=18006 swapped 63.57421875000000000000 MB (java)
#PID=29315 swapped 63.42187500000000000000 MB (java)