The /proc/PID/smaps
is an extension based on maps, showing the memory
consumption for each of the process's mappings. For each of mappings
there is a series of lines such as the following:
08048000-080bc000 r-xp 00000000 03:02 13130 /bin/bash
Size: 1084 kB
Rss: 892 kB
Pss: 374 kB
Shared_Clean: 892 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 892 kB
Anonymous: 0 kB
LazyFree: 0 kB
AnonHugePages: 0 kB
ShmemPmdMapped: 0 kB
Shared_Hugetlb: 0 kB
Private_Hugetlb: 0 kB
Swap: 0 kB
SwapPss: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 0 kB
VmFlags: rd ex mr mw me dw
Tente
$ for proc in /proc/*; do cat $proc/smaps 2>/dev/null | awk '/Swap/{swap+=$2}END{print swap "\tKB\t''readlink $proc/exe|awk '{print $1}' ''" }'; done | sort -n | awk '{total+=$1}/[0-9]/;END{print total "\tKB\tTotal"}'
0 KB /usr/bin/bash
0 KB /usr/bin/bash
0 KB /usr/bin/bash
0 KB /usr/bin/bash
0 KB /usr/bin/bash
0 KB /usr/bin/docker-containerd
0 KB /usr/bin/docker-containerd-shim
0 KB /usr/bin/docker-containerd-shim
0 KB /usr/bin/docker-proxy
0 KB /usr/bin/docker-proxy
0 KB /usr/bin/docker-proxy
0 KB /usr/bin/gawk
0 KB /usr/bin/readlink
0 KB /usr/bin/sleep
0 KB /usr/bin/sort
0 KB /usr/bin/ssh
0 KB /usr/bin/ssh
0 KB /usr/bin/ssh-agent
0 KB /usr/libexec/postfix/pickup
0 KB /usr/libexec/postfix/qmgr
0 KB /usr/sbin/atd
0 KB /usr/sbin/dnsmasq
0 KB /usr/sbin/dnsmasq
0 KB /usr/sbin/sedispatch
0 KB /usr/sbin/sshd
0 KB /usr/sbin/sshd
28 KB /usr/sbin/chronyd
32 KB /usr/sbin/audispd
84 KB /usr/sbin/avahi-daemon
88 KB /usr/lib/systemd/systemd-logind
100 KB /usr/bin/tail
104 KB /usr/sbin/crond
156 KB /usr/sbin/avahi-daemon
192 KB /usr/lib/systemd/systemd-journald
196 KB /usr/bin/bash
196 KB /usr/bin/dbus-launch
...
14872 KB /usr/bin/Xvnc
20048 KB /usr/lib64/firefox/firefox
40176 KB /usr/lib64/firefox/firefox
108848 KB /usr/sbin/mysqld
267144 KB Total
Isso realmente diz que o mysql está usando mais troca.
$ free -k
total used free shared buff/cache available
Mem: 1883740 1044212 112132 14320 727396 520304
Swap: 2097148 265784 1831364
A saída de
free
não parece muito difícil no meu caso