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

How to monitor CPU in Linux

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article mainly introduces how to monitor CPU in Linux, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand.

Linux performance Monitoring CPU

1. Do not exceed 3 for each CPU, for example, do not exceed 6 for dual-core CPU

two。 If CPU is running at full load, it should conform to the following distribution

A) User Time:65%~70%

B) System Time:30%~35%

C) Idle:0%~5%

3. For context switching, combined with CPU utilization, if CPU usage meets the above distribution, a large number of context switching is acceptable.

The commonly used monitors are vmstat, top,dstat and mpstat.

# vmstat 1

Procs-memory--swap---io-----system---cpu

R b swpd free buff cache si so bi bo in cs us sy id wa

00 104300 16800 95328 72200 00 5 26 7 14 4 1 95 0

00 104300 16800 95328 72200 00 0 24 1021 64 1 1 98 0

00 104300 16800 95328 72200 00 00 1009 59 1 1 98 0

R indicates the size of the running queue

B indicates the number of threads block due to IO waits

In indicates the number of interrupts

Cs indicates the number of context switches

Us represents the user's CPU time

Sys represents system CPU time

Wa indicates the time that CPU was in the idle state due to IO waiting

Id represents the total time that CPU has been in the idle state.

Dstat can give the number of interrupts generated by each device:

# dstat-cip 1

-total-cpu-usage---- interrupts--- procs

Usr sys idl wai hiq siq | 15 169 185 | run blk new

6 1 91 200 | 12 013 | 0 0 0

1 099 000 | 0 06 | 0 0 0

00 100 000 0 | 18 0 2 | 00 0

00 100 000 0 | 00 3 | 00 0

We can see that there are three device numbers 15169 and 185. For the relationship between the device name and the device number, we can refer to the file / proc/interrupts, where 185 represents the network card eth2.

# cat / proc/interrupts

CPU0

0: 1277238713 IO-APIC-edge timer

6: 5 IO-APIC-edge floppy

7: 0 IO-APIC-edge parport0

8: 1 IO-APIC-edge rtc

9: 1 IO-APIC-level acpi

14: 6011913 IO-APIC-edge ide0

15: 15761438 IO-APIC-edge ide1

169: 26 IO-APIC-level Intel 82801BA-ICH2

185: 16785489 IO-APIC-level eth2

193: 0 IO-APIC-level uhci_hcd:usb1

Mpstat can show the health of each CPU, for example, the system has four CPU. We can see:

# mpstat-P ALL 1

Linux 2.4.21-20.ELsmp (localhost.localdomain) 05Unix 23 Universe 2006

05:17:31 PM CPU user nice system idle intr/s

05:17:32 PM all 0.00 0.00 3.19 96.53 13.27

05:17:32 PM 00.00 0.00 0.00 100.00 0.00

05:17:32 PM 1 1.12 0.00 12.73 86.15 13.27

05:17:32 PM 2 0.00 0.00 0.00 100.00 0.00

05:17:32 PM 3 0.00 0.00 0.00 100.00 0.00

Thank you for reading this article carefully. I hope the article "how to monitor CPU in Linux" shared by the editor will be helpful to everyone. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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