title: How to convert process cpu usage in clock ticks to percentage?
body: <p>I setup collectd on my Debian 6 virtual machine for monitoring and performance analysis. Collectd's <strong>processes</strong> 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.</p>
  
  <p>By looking at collectd's source code (<a href="https://github.com/collectd/collectd/blob/master/src/processes.c" rel="nofollow">https://github.com/collectd/collectd/blob/master/src/processes.c</a> - in the <em>ps_read_process</em> function) , I figured out this data is read from the <strong>/proc/$pid/stat</strong> file of the process. The proc man page  (link- <a href="http://man7.org/linux/man-pages/man5/proc.5.html" rel="nofollow">http://man7.org/linux/man-pages/man5/proc.5.html</a>) says the cpu usage there is measured in clock ticks.</p>
  
  <p>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?</p>