Hi all,

I want to write a program in python to capture memory and cpu readings of a process which is running on linux server and save the readings in a tabular format to any .doc or .csv file. Got to know that 'top' command would give the cpu and memory readings which a process occupies/utilises on the linux server. As I am quite new to Python, I am not sure what functions can be used to achieve this requirement.

Is this very simple program to do it, can someone guide/help me in it. Also,can someone share me a sample python script if any such available.


There is a great module named <psutil> which can tell you all this

import psutil

for proc in psutil.process_iter():
        pinfo = proc.as_dict()
    except psutil.NoSuchProcess:

To save the data into tabular format, you could use a simple library such as <tablib>.