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

5

3

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:

PROCESS    CPU    RAM    VIRTUAL
name1    %    MB    MB
name2    %    MB    MB
...etc..etc

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)

CPU USAGE BY PROCESS:
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.

Inbar Rose

Posted 2012-12-04T13:43:04.307

Reputation: 133

I believe collectd can do what you want. http://collectd.org/ It'll produce rrdtool files, which you can graph however.

– derobert – 2012-12-04T16:18:05.903

Answers

8

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

gertvdijk

Posted 2012-12-04T13:43:04.307

Reputation: 3 396

Looks like a good start - but can this support the type of access I require? via - date/time scope (range) access? if not, will it have the date/time of the specific entry so I can do my own parsing? For how long does it keep old information? Can I decide what information it collects? – Inbar Rose – 2012-12-04T13:59:22.980

2@InbarRose That's just RTFM imo as I already pointed out in my answer. I suggest to ask a more specific question if you can't get it to do what you want. – gertvdijk – 2012-12-04T14:04:55.647