如何获得在Linux上的整体CPU使用情况(例如57%) [英] How to get overall CPU Usage (e.g. 57%) on Linux

查看:126
本文介绍了如何获得在Linux上的整体CPU使用情况(例如57%)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何可以得到一个系统CPU使用率和present它%(在bash),例如

I am wondering how you can get a system cpu usage and present it in % (in bash) e.g.

示例输出:

57%

如果在的情况下,有超过1个核心,这将是很好,如果平均比例可以计算出

If in the case there were more than 1 core, it would be nice if an average percentage could be worked out

推荐答案

您可以试试:

top -bn1 | grep "Cpu(s)" | \
           sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | \
           awk '{print 100 - $1"%"}'

这篇关于如何获得在Linux上的整体CPU使用情况(例如57%)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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