Postgresql – Measure CPU and Memory usage while running pgbench

performancepostgresql-9.4postgresql-performance

what is the best way to capture the usage of CPU and memory while running pgbench? The only way I can think of is to read the info from top header.

what I do now

  1. I run top command by print it out in a log file.
  2. Then grep the cpu and memory in another txt file
  3. Later I download the txt file and import it in excel file to get the average value of Cpu usage and Memory usage
  4. The result of pgbench will be put together in the excel file

Is there any tips or standard of procedure to implement the TPC-B as well as monitor the resources.

Best Answer

I show some tools I know.

pg_activity is a simple monitoring tool like top.

pg_statsinfo and pg_stats_reporter are high quality utilities that monitor statistics and the activity of PostgreSQL as well as Operating system.

There are some general purpose monitoring tools such as Cacti and Munin. Those support postgres by providing modules and they can easily be used.

BTW, I know a great book: The Art of Computer Systems Performance Analysis. This gives you some hints for benchmarking.