Memory Usage¶
I have uploaded a python script here that can be added to a server and run by the root user. This script is useful when looking into what services are using what amount of memory.
The script can just be run with python ~/ps_mem.py
(if it's uploaded in the user's home directory).
It is usually more helpful to pipe the output to a grep command to look for a certain service e.g. python ~/ps_mem.py | grep php-fpm
The output for the unfiltered command will look like the below:
Private + Shared = RAM used Program
4.0 KiB + 21.5 KiB = 25.5 KiB agetty
148.0 KiB + 35.0 KiB = 183.0 KiB crond
164.0 KiB + 46.0 KiB = 210.0 KiB irqbalance
140.0 KiB + 91.5 KiB = 231.5 KiB master
192.0 KiB + 60.5 KiB = 252.5 KiB auditd
252.0 KiB + 44.5 KiB = 296.5 KiB chronyd
424.0 KiB + 50.5 KiB = 474.5 KiB systemd-udevd
216.0 KiB + 275.5 KiB = 491.5 KiB shim.sh
500.0 KiB + 97.5 KiB = 597.5 KiB qmgr
756.0 KiB + 57.0 KiB = 813.0 KiB lvmetad
736.0 KiB + 78.5 KiB = 814.5 KiB dbus-daemon
608.0 KiB + 255.5 KiB = 863.5 KiB tuned
732.0 KiB + 312.0 KiB = 1.0 MiB cvlaunchd
928.0 KiB + 151.5 KiB = 1.1 MiB snmpd
1.0 MiB + 39.5 KiB = 1.1 MiB systemd-logind [updated]
468.0 KiB + 737.5 KiB = 1.2 MiB vsftpd (3)
1.2 MiB + 319.5 KiB = 1.6 MiB trivial-rewrite
1.3 MiB + 320.5 KiB = 1.6 MiB pickup
1.3 MiB + 319.5 KiB = 1.6 MiB bounce
956.0 KiB + 695.5 KiB = 1.6 MiB zabbix_agentd (7)
1.4 MiB + 320.5 KiB = 1.7 MiB cleanup
1.8 MiB + 341.0 KiB = 2.1 MiB bash
2.0 MiB + 127.0 KiB = 2.1 MiB polkitd
1.7 MiB + 681.5 KiB = 2.4 MiB ClMgrS
2.4 MiB + 70.5 KiB = 2.5 MiB systemd
2.6 MiB + 33.5 KiB = 2.7 MiB cvfwd
2.4 MiB + 631.0 KiB = 3.0 MiB sshd (2)
2.3 MiB + 979.0 KiB = 3.2 MiB smtp (2)
3.6 MiB + 878.5 KiB = 4.4 MiB rsyslogd
9.5 MiB + 807.0 KiB = 10.2 MiB python2.7
11.0 MiB + 1.9 MiB = 12.9 MiB systemd-journald [updated]
13.2 MiB + 206.5 KiB = 13.4 MiB atop
19.3 MiB + 1.1 MiB = 20.4 MiB f2b/server
59.8 MiB + 902.5 KiB = 60.7 MiB cvd
80.8 MiB + 401.5 KiB = 81.2 MiB varnishd (2)
63.6 MiB + 25.0 MiB = 88.6 MiB nginx (9)
496.1 MiB + 340.0 KiB = 496.4 MiB redis-server (3)
843.2 MiB + 1.3 MiB = 844.5 MiB searchd (2)
2.5 GiB + 432.7 MiB = 2.9 GiB php-fpm (65)
17.3 GiB + 306.0 KiB = 17.3 GiB mysqld
---------------------------------
21.8 GiB
=================================