3

I setup collectd on my Debian 6 virtual machine for monitoring and performance analysis. Collectd's processes plugin provides statistics about a process' cpu usage, though what units these statistics have is not documented anywhere. It's certainly not jiffies or milliseconds, since the total cpu usage of several processes could go as high as 400,000 (of some unknown unit) per second on a 4 core virtual machine.

By looking at collectd's source code (https://github.com/collectd/collectd/blob/master/src/processes.c - in the ps_read_process function) , I figured out this data is read from the /proc/$pid/stat file of the process. The proc man page (link- http://man7.org/linux/man-pages/man5/proc.5.html) says the cpu usage there is measured in clock ticks.

This is nice, but clock ticks are a little arbitrary for monitoring and performance analysis. I'd like to convert the clock ticks value to something more meaningful, ideally percentage of total cpu time. How can I do that in a portable way, without just assuming my processor provides 3GHZ of clock ticks?

6
  • Would this help? serverfault.com/questions/648704/… Commented Oct 13, 2015 at 18:35
  • Not quite. sysconf(_SC_CLK_TCK) returns 100 for me, which means every second i have (4 cores) * (100 ticks) = 400 ticks. How come some processes use thousands of ticks or more? Commented Oct 14, 2015 at 5:38
  • 4 physical cores? No HT? Commented Oct 14, 2015 at 6:04
  • I'm using a vmware workstation virtual machine (what's HT?) Commented Oct 14, 2015 at 6:10
  • HyperThreading. I'm not sure you can apply the same calculations you do for physical hardware to a VM. It might allow for bursts, etc. I'm not an expert tho, so maybe you get a better answer from someone :) Commented Oct 14, 2015 at 6:12

1 Answer 1

2

Further inspection of collectd's code revealed that the cpu usage is converted to microseconds.

Also, turns out a similar question was already asked and answered here.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.