如何动态监控Linux上每个核心CPU的使用率?

时间:2023-02-05 20:34:37

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

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

3 个解决方案

#1


47  

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 top in the terminal

在终端输入顶部

then type 1

然后键入1

#2


3  

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

您可以使用dstat为网络分页和系统提供更多有用的信息。可以在文件(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

#3


3  

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

你可能会发现一个名为htop的工具很有用。你提到用户模式和内核,所以我假设你来自Windows。 htop与Windows任务管理器略微相似,但它可能不会预装在Linux系统上。

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

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

#1


47  

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 top in the terminal

在终端输入顶部

then type 1

然后键入1

#2


3  

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

您可以使用dstat为网络分页和系统提供更多有用的信息。可以在文件(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

#3


3  

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

你可能会发现一个名为htop的工具很有用。你提到用户模式和内核,所以我假设你来自Windows。 htop与Windows任务管理器略微相似,但它可能不会预装在Linux系统上。

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

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