Afficher la RAM des process les plus consommateurs

Voici comment afficher la liste des 10 processus les plus consommateurs et la RAM utilisée par ces derniers.

# ps -eo size,pid,user,command | sort -rn | head -10 | awk '{hr[1024**2]="GB"; hr[1024]="MB";for (x=1024**3; x>=1024; x/=1024) {if ($1>=x) { printf ("%-6.2f %s ", $1/x, hr[x]); break }} } { printf ("%-6s %-10s ", $2, $3) }{ for ( x=4 ; x<=NF ; x++ ) { printf ("%s ",$x) } print ("\n") }'
5.64   GB 28817  mysql      /apps/mysql/cluster-7.4.11/bin/ndbd --ndb-connectstring=vl-d-pxx-12:1186,vl-d-pxx-26:1186 --ndb-nodeid=2 --foreground=true

2.34   GB 2000   mysql      mysql-monitor-agent -java-home /apps/mysql/memagent/java -server -Xms32m -Xmx64m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/apps/mysql/memagent/logs/mysql-monitor-agent.hprof -XX:OnOutOfMemoryError=/apps/mysql/memagent/bin/agentRestart.sh -user mysql -pidfile /apps/mysql/memagent/mysql-monitor-agent.pid -wait 90 -outfile /apps/mysql/memagent/logs/mysql-monitor-agent.stdout -errfile /apps/mysql/memagent/logs/mysql-monitor-agent.stderr -classpath /apps/mysql/memagent/bin/bootstrap:/apps/mysql/memagent/lib/commons-daemon-1.0.10.jar -DMYSQL_AGENT_HOME=/apps/mysql/memagent -Djava.library.path=/apps/mysql/memagent/lib -showversion -procname mysql-monitor-agent com.mysql.etools.agent.runtime.Bootstrap --agent-instance-dir=/apps/mysql/memagent

1.15   GB 14832  root       python /usr/bin/goferd

1.05   GB 2582   root       /apps/ITM/lx8266/lz/bin/klzagent

465.77 MB 1948   mysql      /apps/mysql/mcm/libexec/mcmd --plugin-dir=/apps/mysql/mcm/lib/mcmd --defaults-file=/apps/mysql/mcm/etc/mcmd.ini --daemon --pid-file=/apps/mysql/mcm/mcmd.pid

397.02 MB 4054   root       /apps/ITM/lx8266/lz/bin/kcawd

370.44 MB 1660   root       /sbin/rsyslogd -i /var/run/syslogd.pid -c 5

102.05 MB 3685   root       /usr/IBM/TWA/00svczc1/TWS/bin/JobManager

49.28  MB 15067  root       sort -rn

22.54  MB 1738   root       /apps/tad4d/lmt/tlmagent.bin

Sources: