加入收藏 | 设为首页 | 会员中心 | 我要投稿 大连站长网 (https://www.0411zz.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 服务器 > 系统 > 正文

Linux中计算CPU使用率的办法是什么?

发布时间:2021-11-08 21:47:48 所属栏目:系统 来源:互联网
导读:本文主要给大家介绍Linux中计算CPU使用率的方法,下文有很详细的介绍和示例,感兴趣的朋友可以了解一下,接下来跟随小编一起来看看吧。 Linux中计算特定CPU使用率的方法: 1. 背景知识 在/proc/stat中可以查看每一个CPU的使用情况的,如下图: 其中cpu(0/1
   本文主要给大家介绍Linux中计算CPU使用率的方法,下文有很详细的介绍和示例,感兴趣的朋友可以了解一下,接下来跟随小编一起来看看吧。
 
 
 
Linux中计算特定CPU使用率的方法:
 
1. 背景知识
 
在/proc/stat中可以查看每一个CPU的使用情况的,如下图:
 
 
 
其中cpu(0/1/2/…)后面的那十个数字含义如下:
 
/proc/stat
kernel/system statistics.  Varies with architecture.  
Common entries include:
     user nice system idle iowait  irq  softirq steal guest guest_nice
cpu  4705 356  584    3699   23    23     0       0     0        0
cpu0 1393280 32966 572056 13343292 6130 0 17875 0 23933 0
   The amount of time, measured in units of USER_HZ
   (1/100ths of a second on most architectures, use
   sysconf(_SC_CLK_TCK) to obtain the right value), that
   the system ("cpu" line) or the specific CPU ("cpuN"
   line) spent in various states:
   user   (1) Time spent in user mode.
   nice   (2) Time spent in user mode with low priority
          (nice).
   system (3) Time spent in system mode.
   idle   (4) Time spent in the idle task.  This value
          should be USER_HZ times the second entry in the
          /proc/uptime pseudo-file.

(编辑:大连站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!