Connaître les processus qui utilisent la SWAP
jeudi 7 juin 2018
par
popularité : 3%
par
popularité : 3%
Voici le script :
#!/bin/bash
# Get current swap usage for all running processes
# Usage: ./getswap.sh | sort -n -k 5
# Erik Ljungstrom 27/05/2011 mod by Poil
SUM=0
OVERALL=0
for DIR in /proc/[0-9]*; do
PID=${DIR##*\/}
PROGNAME=$(ps -p ${PID} -o comm --no-headers)
PROGPATH=$(cat /proc/${PID}/cmdline)
for SWAP in $(awk '/Swap/ { print $2}' ${DIR}/smaps 2>/dev/null);do
SUM=$(( SUM + SWAP ))
done
echo "PID=$PID - Swap used: ${SUM} - (${PROGNAME} - ${PROGPATH})"
OVERALL=$(( OVERALL + SUM))
SUM=0
done
echo "Overall swap used: $OVERALL"