0

This is a bit of a tricky one. I'm trying to plot CPU usage in percentage of usage at certain point of time. To do this I take the samples from /proc/stat - these are absolute samples and they looks like this:

app01.cpu.total.user    45997117    1358816118
app01.cpu.total.nice    165511          1358816118
app01.cpu.total.system  36679893    1358816118
app01.cpu.total.idle    3519926642  1358816118
app01.cpu.total.iowait  3854916         1358816118
app01.cpu.total.irq 2553            1358816118
app01.cpu.total.softirq 189828          1358816118
app01.cpu.total.steal   4497297         1358816118
app01.cpu.total.guest   0           1358816118

The function I'm using to display these is:

scale(divideSeries(stats.app01.cpu.total.user,sumSeries(stats.app01.cpu.total.*)), 100)

Which should basically display the results in percentage. I noticed that I get the same results when I plot the graph like this:

asPercent(stats.app01.cpu.total.user,sumSeries(stats.app01.cpu.total.*))

My problem with this is that I noticed that the curve is constantly growing - by tiny little fraction but it is growing - which I can't really make much sense of why. In fact it should be fairly flat and dropping and growing depending on the CPU usage at the time when the sample was taken. I would certainly NOT expect a growing trend. But I might missing something hence I'm turning here for some help.

milosgajdos
  • 851
  • 1
  • 14
  • 32

1 Answers1

4

The values reported by /proc/stat are a measure of the total amount of CPU time spent in each category of work since the system first booted. In order to get a measure of the CPU activity at a point in time you need to take the derivative of these values.

asPercent(derivative(stats.app01.cpu.total.user),
          sumSeries(derivative(stats.app01.cpu.total.*)))
Ben Butler-Cole
  • 2,011
  • 1
  • 17
  • 23