Editing
Linux commands
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== System CPU usage === ==== Using mpstat command to obtain CPU usage ==== Example result of {{kbd | key=<nowiki>mpstat 2 2 | grep -E '^Average'</nowiki>}} on {{Linux}} <pre> Average: all 1.31 0.00 0.25 0.00 0.00 0.00 0.00 0.00 0.00 98.43 </pre> The output of the mpstat command includes an "Average" line, which provides detailed information about CPU usage, similar to the %Cpu(s) line in the top command but with a slightly different format. Here's an explanation of the columns in the "Average" line: * all: This represents the average values for all CPU cores. The subsequent columns represent percentages of CPU usage: * The first column (1.31) is the CPU usage by user-space processes, indicating the percentage of time the CPU is occupied by user programs and processes. * The second column (0.00) is the CPU usage by system kernel processes, indicating the percentage of time the CPU is occupied by the operating system kernel. * The third column (0.25) is the CPU usage by processes with a "nice" priority, representing the percentage of CPU time used by processes adjusted with the nice command. * The fourth column (0.00) is the CPU's idle time, indicating the percentage of time the CPU is not executing any tasks. * The fifth column (0.00) is the CPU's time spent waiting for I/O operations to complete, indicating the percentage of time the CPU is waiting for disk or other I/O device responses. * Columns six through eleven (0.00 to 0.00) represent CPU usage in other states, such as the time spent handling hardware or software interrupts and time spent in virtualized environments with CPU steal time. * The last column (98.43) indicates the percentage of time the CPU is idle, representing the time when the CPU is not executing any tasks. In the above example, the CPU usage is as follows: * User processes have used 1.31% of CPU time. * System kernel processes have used 0.00% of CPU time. * There are no "nice" priority processes using CPU time. * The CPU is idle for 98.43% of the time. * There is no time spent waiting for I/O operations to complete. * There is no time spent handling hardware or software interrupts. * There is no CPU steal time in a virtualized environment. ==== Using top command to obtain CPU usage ==== # Command: Using top command e.g. {{kbd | key=<nowiki>top</nowiki>}} on {{Linux}} or {{Mac}} # Command: Using top command e.g. {{kbd | key=<nowiki>top -l 2 | grep -E '^CPU'</nowiki>}} on {{Mac}} # Command: Using top command e.g. {{kbd | key=<nowiki>top -n 1 | grep '%Cpu(s)'</nowiki>}} on {{Linux}} Example result of {{kbd | key=<nowiki>top -n 1 | grep '%Cpu(s)'</nowiki>}} <pre> %Cpu(s): 1.5 us, 1.5 sy, 0.0 ni, 96.9 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st </pre> The result provided is the information about CPU usage obtained through the `top` command. It shows the percentages of different CPU states, and each column is explained as follows: * `%Cpu(s)`: This is the header indicating that the following numbers are percentages related to CPU usage. * `us` (User): It represents the CPU usage by user-space processes, which includes the percentage of time the CPU is occupied by user programs and processes. In this case, it's 1.5%, indicating that 1.5% of CPU time is used for running user programs. * `sy` (System): It represents the CPU usage by system kernel processes, indicating the percentage of time the CPU is occupied by the operating system kernel. In this case, it's 1.5%, indicating that 1.5% of CPU time is used for handling operating system kernel tasks. * `ni` (Nice): It represents the CPU usage by processes with a "nice" priority, which includes the percentage of CPU time used by processes adjusted with the `nice` command. In this case, it's 0%, indicating that there are no "nice" processes running. * `id` (Idle): It represents the percentage of time the CPU is in an idle state, indicating the percentage of time the CPU is not executing any tasks. In this case, it's 96.9%, meaning that 96.9% of CPU time is idle. * `wa` (IO Wait): It represents the CPU usage while waiting for I/O operations to complete, indicating the percentage of time the CPU is waiting for disk or other I/O device responses. In this case, it's 0%, indicating that the CPU is not waiting for I/O to complete. * `hi` (Hardware IRQ): It represents the CPU usage caused by hardware interrupts, indicating the percentage of time spent handling hardware device interrupts. In this case, it's 0%, indicating that the CPU is not handling hardware interrupts. * `si` (Software IRQ): It represents the CPU usage caused by software interrupts, indicating the percentage of time spent handling software interrupts. In this case, it's 0%, indicating that the CPU is not handling software interrupts. * `st` (Steal Time): It represents the "steal time" in a virtualized environment, indicating the percentage of time a virtual machine's CPU is taken away when sharing host CPU resources with other virtual machines. In this case, it's 0%, meaning there is no virtualization steal time. In summary, this output indicates the following CPU usage: * User programs are using 1.5% of CPU time. * System kernel tasks are using 1.5% of CPU time. * There are no "nice" processes running. * 96.9% of CPU time is idle. * There is no time spent waiting for I/O operations to complete. * There is no time spent handling hardware or software interrupts. * There is no virtualization steal time.
Summary:
Please note that all contributions to LemonWiki共筆 are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
LemonWiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Current events
Recent changes
Random page
Help
Categories
Tools
What links here
Related changes
Special pages
Page information