If we would like to sort out the running or queueing process as per swap usage we can do like :
#top
Then press capital "o" (ie "O") followed by "p" and press enter. Now processes should be sorted by their swap usage.
We can also use bash script to pick up the process from /proc file system. So, use the following script :
-----
#!/bin/bash
# Get current swap usage for all running processes
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"
-----
Save it as getswapusage.sh and change its permission like :
#chmod 755 getswapusage.sh
Now run it like :
#./getswapusage.sh |sort -n -k 5
We can view swap usage at that particular moment by particular process.
We can also monitor total swap usage by following command :
#watch cat /proc/meminfo
Friday, 16 September 2011
How to find out which process is using swap space?
Posted on 03:31 by Unknown
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment