2

I want to do performance testing in linux environment for a C++ application. I need to measure the CPU usage, Memory usage of the application. This application is a multi threaded application.

In this requirement I came across two Tools/Utilities (sar and top). My problem now is if I want to monitor cpu usage by user I can use top utility for this but not sure if this is available in sar utility. If I am wrong on my approach please direct me to the correct path on how to do performance testing in linux environment.

As a end note I use putty to login to the remote linux machine thus any GUI based tool will not help me.

Any help will be of great use to me.

  • So are you just asking whether sar can measure performance on a per-user basis? – user246 Jul 17 '13 at 11:41
2

Try taking a look through this site:

http://www.cyberciti.biz/tips/how-do-i-find-out-linux-cpu-utilization.html

A little over half-way down is some 'ps' stuff that is probably helpful. The biggest problem with top is that it's a pain to run and parse as part of a bash script and I'd definitely recommend that you want to hit these commands, parse them, and collect the data over time so you can look for spikes and trends.

sed and awk will be your friends in parsing that data. I'm not sure what your comfort level in linux is, but if you're not familiar with those commands, I'd take a little time to learn them.

  • Hi, I was more interested in getting to know the performance of the application in terms of CPU utilization, Disk usage and IO. So I used pidstat command. But I came acrossa set of values as below minflt/s majflt/s VSZ RSS %MEM kB_rd/s kB_wr/s kB_ccwr/s 49 0 217532 18784 0.01 -1 -1 -1 – Subiah R Nagarajan Jul 22 '13 at 5:10
2

I upvoted Daniel's answer, another approach would be to set up a monitoring tool like Graphite to monitor and keep historical data for you. This is also useful in terms of monitoring/alerting for your product in general: http://graphite.wikidot.com/start

  • Thanks Sam woods for the reply and support to your fellow community member. – Subiah R Nagarajan Jul 22 '13 at 5:09
0

You should be able to find a lot of information in the /proc filesystem for this. The advantage here is that it accessing it will create the most minimal cpu load compared to top or other monitoring tools. If you are attempting to use top and measuring on a per user basis you will include around a 1% overhead for just running top.

  • /proc/$PID/status - has most of the info you need in a single file
  • /proc/$PID/uid_map - the uid this process runs as
  • /proc/$PID/task - children of this process
  • /proc/$PID/io - read and write stats

You could then scp the files of the box periodically and then analyse after the test.

This answer from askubuntu shows several methods for seing just a users cpu load https://askubuntu.com/questions/808052/cpu-usage-per-user

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.