user nice system idle iowait irq softirq steal guest guest_nice
cpu 74608 2520 24433 1117073 6176 4054 0 0 0 0
Algorithmically, we can calculate the CPU usage percentage like:
PrevIdle = previdle + previowait
Idle = idle + iowait
PrevNonIdle = prevuser + prevnice + prevsystem + previrq + prevsoftirq + prevsteal
NonIdle = user + nice + system + irq + softirq + steal
PrevTotal = PrevIdle + PrevNonIdle
Total = Idle + NonIdle
# differentiate: actual value minus the previous one
totald = Total - PrevTotal
idled = Idle - PrevIdle
CPU_Percentage = (totald - idled)/totald
cpu 114466 58760 208131 183612 1490 18 5178 0 0 0
cpu0 20966 6912 72976 161278 1200 3 3263 0 0 0
cpu1 18880 6959 39092 4213 20 5 112 0 0 0
cpu2 18665 6782 29917 4321 21 2 50 0 0 0
cpu3 18134 6434 27657 4442 21 2 62 0 0 0
cpu4 10008 8231 10491 2308 63 0 1003 0 0 0
cpu5 9338 8080 9868 2382 64 0 240 0 0 0
cpu6 9210 7570 9186 2392 40 2 226 0 0 0
cpu7 9265 7792 8944 2276 61 4 222 0 0 0
http://stackoverflow.com/questions/23367857/accurate-calculation-of-cpu-usage-given-in-percentage-in-linux
No comments:
Post a Comment