diff options
author | Simon Rettberg | 2023-02-07 14:07:58 +0100 |
---|---|---|
committer | Simon Rettberg | 2023-02-07 14:07:58 +0100 |
commit | 52b3f3651f767b28e0c31ae3516fd6c80155f40f (patch) | |
tree | 7f2f57de86e6eeb62b079d01f483aa8c30f2700a /core/modules/bwlp-stage4-tweaks | |
parent | [debug] Delete old debug_report copy (diff) | |
download | mltk-52b3f3651f767b28e0c31ae3516fd6c80155f40f.tar.gz mltk-52b3f3651f767b28e0c31ae3516fd6c80155f40f.tar.xz mltk-52b3f3651f767b28e0c31ae3516fd6c80155f40f.zip |
[bwlp-stage4-tweaks] Add pswap util
Diffstat (limited to 'core/modules/bwlp-stage4-tweaks')
-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" + |