====== Connaitre la swap par process ====== #!/bin/bash # Get current swap usage for all running processes # Erik Ljungstrom 27/05/2011 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" # ./script.sh | sort -n -k 5| egrep -v "Swap used: 0" Overall swap used: 7604 PID=22282 - Swap used: 8 - (gdm-simple-slav ) PID=1234 - Swap used: 20 - (dhclient3 ) PID=22326 - Swap used: 44 - (hald ) PID=891 - Swap used: 44 - (irqbalance ) PID=1118 - Swap used: 52 - (getty ) PID=1136 - Swap used: 56 - (rtkit-daemon ) PID=321 - Swap used: 72 - (upstart-udev-br ) PID=874 - Swap used: 72 - (getty ) PID=881 - Swap used: 72 - (getty ) PID=884 - Swap used: 72 - (getty ) PID=887 - Swap used: 72 - (getty ) PID=870 - Swap used: 76 - (getty ) PID=1 - Swap used: 84 - (init ) PID=729 - Swap used: 88 - (dbus-daemon ) PID=746 - Swap used: 92 - (avahi-daemon ) PID=896 - Swap used: 120 - (cron ) PID=897 - Swap used: 120 - (atd ) PID=1700 - Swap used: 124 - (udisks-daemon ) PID=9999 - Swap used: 148 - (upowerd ) PID=1701 - Swap used: 152 - (udisks-daemon ) PID=753 - Swap used: 164 - (avahi-daemon ) PID=740 - Swap used: 192 - (gdm-binary ) PID=759 - Swap used: 228 - (modem-manager ) PID=833 - Swap used: 264 - (wpa_supplicant ) PID=712 - Swap used: 272 - (rsyslogd ) PID=969 - Swap used: 272 - (cupsd ) PID=9972 - Swap used: 272 - (acpid ) PID=22321 - Swap used: 296 - (gdm-session-wor ) PID=747 - Swap used: 300 - (NetworkManager ) PID=28620 - Swap used: 304 - (udevd ) PID=28621 - Swap used: 308 - (udevd ) PID=323 - Swap used: 312 - (udevd ) PID=686 - Swap used: 332 - (mount.ntfs-3g ) PID=758 - Swap used: 520 - (console-kit-dae ) PID=1140 - Swap used: 672 - (polkitd ) PID=1827 - Swap used: 1308 - (evolution-data- )