diff options
-rwxr-xr-x | core/modules/bwlp-stage4-tweaks/data/opt/openslx/bin/pswap | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/core/modules/bwlp-stage4-tweaks/data/opt/openslx/bin/pswap b/core/modules/bwlp-stage4-tweaks/data/opt/openslx/bin/pswap new file mode 100755 index 00000000..42e4fac1 --- /dev/null +++ b/core/modules/bwlp-stage4-tweaks/data/opt/openslx/bin/pswap @@ -0,0 +1,20 @@ +#!/bin/sh + +# Get current swap usage for all running processes +# Erik Ljungstrom 27/05/2011 +OVERALL=0 +for PID in `find /proc/ -maxdepth 1 -type d -regex "/proc/[0-9]+" | cut -d / -f 3`; do + SUM=0 + DIR="/proc/$PID" + PROGNAME=`ps -p $PID -o comm --no-headers` + for SWAP in `grep ^Swap $DIR/smaps 2>/dev/null| awk '{ print $2 }'`; do + SUM=$(( $SUM + $SWAP )) + done + SUM=$(( $SUM / 1024 )) + [ "$SUM" -eq "0" ] && continue + echo "$SUM MiB by PID=$PID - ($PROGNAME)" + OVERALL=$(( $OVERALL + $SUM )) +done + +echo "Overall swap used: $OVERALL MiB" + |