如何从Shell确定当前的CPU使用率? [英] How can I determine the current CPU utilization from the shell?

查看:488
本文介绍了如何从Shell确定当前的CPU使用率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何确定Linux中Shell的当前CPU使用率?

How can I determine the current CPU utilization from the shell in Linux?

例如,我得到的平均负载如下:

For example, I get the load average like so:

cat /proc/loadavg

输出:

0.18 0.48 0.46 4/234 30719

推荐答案

Linux没有提供当前CPU利用率的任何系统变量.取而代之的是,您必须多次读取/proc/stat:cpu(n)行中的每一列都给出了总的CPU时间,并且您必须对其进行后续读取以获得百分比.请参阅本文档,以了解各列的含义.

Linux does not have any system variables that give the current CPU utilization. Instead, you have to read /proc/stat several times: each column in the cpu(n) lines gives the total CPU time, and you have to take subsequent readings of it to get percentages. See this document to find out what the various columns mean.

这篇关于如何从Shell确定当前的CPU使用率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆