Here are two script which helps the administrator to find exact program and user consuming memory in their systems. The first program is written in python which provide us a list using program running and its memory usage (both RSS and shared memory).
Listing RAM usage per Program
For example this script will report RAM used by all httpd process together. In detail it reports :
- sum(private RAM for program processes) + sum(Shared RAM for program processes)
The shared RAM is problematic to calculate, and this script automatically, selects the most accurate method available for your
kernel. Ssh your server as root.
- # cd /root/
# wget http://gnutoolbox.com/download/linux/scripts/mem.py
# chmod 755 mem.py
# ./mem.py
Since its a python script it cannot be executed using sh mem.py. The output will look similar below :
Listing RAM usage per User
Using the ps -eo user,rss command as background, here is another script to list the user memory usage.
- # cd /root/
# wget http://gnutoolbox.com/download/linux/scripts/mem-per-user.sh
# chmod 755 mem-per-user.sh
# ./mem-per-user.sh
The output will look similar to below.