

To start the top command you just type top at the command line: The most common is probably using the top command. There are several different ways to see the various CPU statistics. See our blog post Restricting process CPU usage using nice, cpulimit, and cgroups for more information on nice. By default processes on Linux are started with a niceness of 0. The niceness level ranges from -20 (most favorable scheduling) to 19 (least favorable). Niceness is a way to tweak the priority level of a process so that it runs less frequently. For example, user space programs can be categorized as those running under their initial priority level or those running with a nice priority. These three meta states can be further subdivided. Running the kernel, servicing interrupts or managing resources.Running a user space program, like a command shell, an email server, or a compiler.Idle, which means it has nothing to do.There are 3 general states your CPU can be in: You see the CPU metrics:īut what do all of those 2-letter abbreviations mean? The 3 CPU states Your Linux server is running slow, so you follow standard procedure and run top. I do not know if this was your issue or not, nor if it is the only issue.Updated version of an article first published on February 24th, 2015. This hack seems to fix this issue: top -b -n 2 | grep Cpu | sed 's/:/ /g' | awk '' | sed -n '2 p' Indeed, the output running your command gives an incorrect answer sometimes (running it in a loop,where the real load is always 100%): CPU Load: 100.00 Looking in more detail, I'll add the field number below (remember, the default field delimiters are space and tab): %Cpu(s): 98.9 us, 1.1 sy, 0.0 ni, 0.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 stġ 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 Notice in the 2nd printing there are only 16 fields instead of 17, because the normal space between the : and the first digit of the "us" load isn't there having been taken up by the "1", and therefore the referencing would be wrong.

One example, there may be more: top -b -n 2 | grep Cpu You are counting fields backwards from the last one, assuming the number is always the same.
