0

Often I feel the need to run some computation on the data about my system load. For instance about the data that top shows. And possibly iotop and htop as well.

Some of the things I'd like to do are the following:

  1. Compute average, max and min CPU load (divided in user time, system, idle etc, like top shows it) for each core (or for the average core) over 10 seconds.

  2. Computer average, max and min CPU time for each process over 10 seconds. And then compute the average, max and min for each process sharing the same process name or Group ID.

  3. Compute the total amount of resident RAM used by all the chromium or firefox processes, without counting shared memory regions twice.

  4. Compute the average network usage and max bandwidth per process and per interface over a few minutes.

I know that top and ps are fetching their data from /proc, but understanding the semantics for those files and parsing them is harder than I wish: it takes a proper script/program. I'd love to be able to play with this data writing a for loop in my bash.

Is there any abstraction to the system load data which is simple and quick to use?

1 Answer 1

0

top uses ncurses interactively, so the output stream is full of cursor movements. However, it has a -b (batch) option that prints the data every time-interval. So you could parse that with awk. If you don't need all the processes (which it does because it does not have a window size in -b mode) there are options to tailor almost all the outputs. And it does the interval timing for you too, so you don't need to keep re-running the process.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .