Linux: per-process monitor, every 10 minutes, with history access

cpu usagelinuxmemoryprocessvirtual-memory

I really didn't know a better way to ask my question, hence you get a horribly named question.

I will explain what i want to do, maybe that will help you help me.

I would like to have my linux machine continuously monitor (every 10 minutes) all the processes on my machine. The information from each process that I require is the name, CPU usage, allocated (virtual) memory, and resident (ram) memory.

If these periodic reports were to be looked at, they would look something like this:

name1    %    MB    MB
name2    %    MB    MB

These reports should be stored in such a way that I can access them at a later date by giving a date/time scope (range). For instance, if I want to see the history of my processes from 12:00:00 1.12.12 till 12:00:00 2.12.12 I can – and it should give me the history of the processes for every 10 minutes between those date/time borders.

The format of the return is not important, that will be handled by a script anyway and can be modified into anything I need.

I have looked into a few things so far, but have not found something that clearly meets my needs. Among the things i searched: sar, free(1), top(1).. and a few other things.

It should be a simple issue, i can already see all this information by simply looking at my htop, but i need only a tool that will gather the desired fields for me for each processes every 10 minutes, and then also let me extract slices of that data based on date/time scopes (ranges).

note: I have limited experience with linux, so please give detailed information.

note2: The desired output will be something like this (after receiving the desired range)

proc_nameA 1,2,2,2,2,2...... numbers represent % usage every 10 minutes...
proc_nameB 4,3,3,6,1,2......

The same idea with the other information.

Best Answer

Try atop.

It will log all of these system information for every 5 or 10 minutes (depending on what your distribution has chosen for you) as a daemon and put that in binary files. Then use

atop -r

To view the contents of today's standard logfile interactively. It's like htop with some extra I/O info which allows you to go back in time and see what happened on those moments. Press t to go forward and Shift+t to go back.

You can also point it to a specific time range. From the manpage:

With the flag -b (begin time) and/or -e (end time) followed by a time argument
of the form HH:MM, a certain time period within the raw file can be selected.

It's just not overly configurable on what to write in the raw files.

I suggest you to read more of the manpage of atop as well to get started, e.g. reading the contents of yesterday's logfile.

Here's how my machine 'zarafa' was performing this morning between 7:35:40 and 7:45:40:

atop screenshot