Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

What is using my Linux swap space?

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"






This post first appeared on DBA-DB2.com, please read the originial post: here

Share the post

What is using my Linux swap space?

×

Subscribe to Dba-db2.com

Get updates delivered right to your inbox!

Thank you for your subscription

×