0

I am using a tool called collectd, under linux, which gives me different cpu stats. I get:

cpu user mode

cpu system mode

cpu nice

cpu idle

cpu wait

cpu interrupt

cpu softirq

cpu steal

now, I'd like to combine these stats in order to get the cpu usage %. Any idea for that?

edit: Looking at the internet it seems that I can obtain, for example, the %cpu used in user space by subtracting two successive measurements of the cpu_user_mode stat (dividing by 100,ofc). Why is that? Those values represent the time cpu spent, from the boot, in those states...why if I subtract two measurements I obtain the %?

Phate
  • 231

1 Answers1

1

If you want the total cpu usage there is the command i use :

top -b -d1 -n1|grep -i "Cpu(s)"|head -c21|cut -d ' ' -f3|cut -d '%' -f1