Linux Memory Usage

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.

 

 

Since its a python script it cannot be executed using sh mem.py. The output will look similar below :

 

Linux Memory usage per program

Listing RAM usage per User

 

Using the ps -eo user,rss command as background, here is another script to list the user memory usage.

 

 

The output will look similar to below.

 

Memory per user