How can more than 100% of CPU utilization be used (top output)?

I am writing a little python script to test some things. later I want to use it to create graphs of resource usage using gnuplot, but first a few tests.

the script looks like

import subprocess

result = subprocess.check_output("top -b -n 1 -c", shell=True).split("\n")

head = result[:5]
body = [x for x in result[7:] if x] #removes empty strings

for line in head:
    print line

csum = 0.0
for line in body:
    print line
    csum += float(line.split()[8])

print "CPU usage of all processes added up", csum, "%"

Running it several times almost always led to the CPU utilization shown> 100%. Sometimes even> 200%. How can it be?

It runs on a virtual machine (virtualbox, ubuntu 14.04 64 bit) with two cores. The host also has two cores.

Should the sum of the usage values ​​of all running processes always be below 100%? I run htop at the same time, and this shows me about 50% of the load on each core.

, , , , top, cpu ? == > ?

0
2

100% - 1 CPU/CORE/Thread. 8 CPU, 800%.

, , , Linux .

+7

SQL, . , mysqld ( mysql) , . "top" UNIX, , 100% . , 100% .

+2

All Articles