SHARE
TWEET

Untitled

a guest Sep 16th, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. # Get current swap usage for all running processes
  3. # Erik Ljungstrom 27/05/2011
  4. # Modified by Mikko Rantalainen 2012-08-09
  5. # Pipe the output to "sort -nk3" to get sorted output
  6. # Modified by Marc Methot 2014-09-18
  7. # removed the need for sudo
  8.  
  9. SUM=0
  10. OVERALL=0
  11. for DIR in `find /proc/ -maxdepth 1 -type d -regex "^/proc/[0-9]+"`
  12. do
  13.     PID=`echo $DIR | cut -d / -f 3`
  14.     PROGNAME=`ps -p $PID -o comm --no-headers`
  15.     for SWAP in `grep VmSwap $DIR/status 2>/dev/null | awk '{ print $2 }'`
  16.     do
  17.         let SUM=$SUM+$SWAP
  18.     done
  19.     if (( $SUM > 0 )); then
  20.         echo "PID=$PID swapped $SUM KB ($PROGNAME)"
  21.     fi
  22.     let OVERALL=$OVERALL+$SUM
  23.     SUM=0
  24. done
  25. echo "Overall swap used: $OVERALL KB"
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top