13 November,2018 by Tom Collins
Question: I'm familiar with how to monitor swap space usage for processes. There is more detail about the methods I've adopted for using vmstat to check swap in and swap out on Linux swap space and DB2 . How can I check what is currently in the Linux wasp space ?
Answer: Sometimes out of curiosity I like to check what is consuming Linux swap space on a server . Various security type scans always appear to abound on servers and I like to differentiate between ad- hoc , regular processes. The more relevant information you've got - allows better decision making.
I use this little script - which lists out all the processes and the swap usage.
SUM=0 OVERALL=0 for DIR in `find /proc/ -maxdepth 1 -type d | egrep "^/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 echo "PID=$PID - Swap used: $SUM - ($PROGNAME )" let OVERALL=$OVERALL+$SUM SUM=0 done echo "Overall swap used: $OVERALL"
Thank you to Erik Ljungstrom for the script
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
Posted by: |