/ proc / stat显示用户,nice,sys,idle,iowait,irq和sirq的刻度,如下所示:
cpu 6214713 286 1216407 121074379 260283 253506 197368 0 0 0
如何使用这些值计算用户的个人利用率(%),等等?就像’top’或’vmstat’中显示的值一样.
最佳答案
从Documentation / filesystems / proc.txt:
(…) These numbers identify the amount of time the CPU has spent performing
different kinds of work. Time units are in USER_HZ (typically hundredths of a second).
因此,要根据您需要的百分比来计算利用率:
>找出机器上USER_HZ的内容
>了解自系统启动以来的时间.
第二个很简单:在同一个文件中有一个btime行,你可以使用它.对于USER_HZ,请查看How to get number of mili seconds per jiffy.
相关文章
- bash - 从/ proc / stat计算CPU使用率
- 使用/ proc/stat在Linux中准确计算CPU利用率
- linux - iostat如何计算CPU闲置时间考虑为%idle或%iowait?
- linux - 如何从/ proc/pid/stat获取应用程序的总CPU使用率?
- 如何获得像“top”命令一样的per-cpu统计信息(system,idle,nice,...)?
- 从/ proc/pid/stat中检索当前堆栈指针
- linux - ethernet smp_affinity vs/proc/interrupts vs/sys/class/net/ethX/device
- linux-kernel - / proc // task // stat中的utime和stime字段多久更新一次?
转载注明原文:python – 从/ proc/stat计算用户,nice,sys,idle,iowait,irq和sirq - 代码日志