I guess the question is, could I somehow calculate the CPU utilization percentage just by reading the /proc/stat once?
# head -1 /proc/stat cpu 67891300 39035 6949171 2849641614 118251644 365498 2341854 0
I am thinking about summarizing the columns except the IOWait (I was reading somewhere that it is counted in the idle) and that would give me the 100% and each individual column could be turned into percentage by (column/100_percent)*100.
- user: normal processes executing in user mode
- nice: niced processes executing in user mode
- system: processes executing in kernel mode
- idle: twiddling thumbs
- iowait: waiting for I/O to complete
- irq: servicing interrupts
- softirq: servicing softirqs
- steal: involuntary wait
- guest: running a normal guest
- guest_nice: running a niced guest
Is this a viable approach or i am totally off the track?