Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if the utilization rate of CPU in Linux system is too high?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Introduction to reading for beginners, may be a variety of process management tools are not familiar with, then encounter Linux system CPU system usage is too high how to do? Then let's study.

View CPU usage

On the Linux system, use the top command to view CPU usage.

% Cpu (s): 0.3 us, 0.1 sy, 0.0 ni, 99.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st

Details of each type of CPU occupation:

Us (user): indicates the percentage of time that CPU has been run by the user. Usually, a high user CPU indicates that an application is busy. Typical user programs are: database, Web server and so on. Sy (sys): indicates the percentage of time that the kernel state of CPU is running (excluding interrupts). Usually, the lower the kernel state CPU, the better, otherwise it indicates that there are some bottlenecks in the system. Ni (nice): represents the CPU time executed by the user process that corrects the process priority with nice. Nice is a correction of the priority of a process, and if the process modifies the priority through it, the CPU cost is counted separately. Id (idle): indicates the percentage of time that CPU is idle, in which case CPU executes a specific virtual process called System Idle Process. Wa (iowait): indicates the time it takes for CPU to wait for the operation to be completed. Usually, the lower the indicator, the better. Otherwise, it indicates that there is a bottleneck in the operation. You can use commands such as iostat to do further analysis. Hi (hardirq): represents the time it takes for CPU to handle hard interrupts. Hard interrupt is sent by peripheral hardware (such as keyboard controller, hardware sensor, etc.), which needs the participation of interrupt controller and is characterized by fast execution. Si (softirq): indicates the time it takes for CPU to process soft interrupts. Soft interrupt is an interrupt signal sent by software programs (such as network transceiver, timing scheduling, etc.), which is characterized by delayed execution. St (steal): indicates the time that CPU is occupied by other virtual machines, only in multiple virtual airport scenes. If the indicator is too high, you can check whether the host or other virtual machines are abnormal. Troubleshoot users with high CPU utilization

User CPU usage reflects the busyness of the application and is usually closely related to the code we write.

Procedure:

1) find the process number that CPU consumes the most through the top command

2) find the thread number that CPU consumes the most through the top-Hp process command (the column name is still PID)

3) output the hexadecimal number corresponding to the thread number through the printf "% x\ n" thread number command

4) the PID process is called in the kernel. For Java applications, you can use the jstack process number | grep hexadecimal thread number-A 10 command to find the thread method stack that consumes the most CPU.

Non-Java applications can use perf to view:

Perf top-p 7574

If prompted with perf: command not found, install using yum install perf.

Perf is a tool in the Linux 2.6 + kernel, the location tools/perf in the kernel source package.

Perf takes advantage of Linux's trace feature and can be used for real-time tracking, counting event counts (perf stat), or diagnosing using sampling (perf record) and reporting (perf report | script | annotate).

Original address of this article: https://www.linuxprobe.com/linux-cpu-top.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report