如何在 Linux 上动态监控每个内核的 CPU 使用情况?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20124508/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 01:25:01  来源:igfitidea点击:

How to dynamically monitor CPU per core usage on Linux?

linuxcpucpu-usage

提问by Rick

I want to dynamically view CPU per core usage, include spending user mode and kernel, how should I do it?

我想动态查看每个核心的 CPU 使用情况,包括用户模式和内核的开销,我应该怎么做?

采纳答案by JoeC

You can view CPU per core usage dynamically by using the top command (Not sure what you meant by spending user mode and kernel tho)

您可以使用 top 命令动态查看每个内核的 CPU 使用情况(不确定使用用户模式和内核是什么意思)

type topin the terminal

键入top在终端

then type 1

然后输入 1

回答by KeshV

You can use dstatwhich spits some more useful information for network paging and system. This information can be captured in files (csv, etc) for future use.

您可以使用dstatwhich 为网络寻呼和系统吐出一些更有用的信息。可以在文件(csv 等)中捕获此信息以供将来使用。

For e.g say your machine has 4 cores. You can do following.

例如,假设您的机器有 4 个内核。您可以执行以下操作。

dstat -C 0,1,2,3,total

If you only want to see stats for cores 2 and 3 you can do following:

如果您只想查看核心 2 和 3 的统计数据,您可以执行以下操作:

dstat -C 2,3

回答by Bill

There is a tool called htopthat you may find useful. You mention user mode and kernel, so I assume you're coming from Windows. htopis slightly more similar to Windows Task Manager than top, but it may not be preinstalled on your Linux system.

有一种称为htop您可能会发现有用的工具。您提到了用户模式和内核,所以我假设您来自 Windows。htop与 Windows 任务管理器略有相似之处top,但它可能未预装在您的 Linux 系统上。

htop homepage:http://hisham.hm/htop/

htop主页:http : //hisham.hm/htop/