2017-04-20 290 views
0

我想findout整體CPU使用率和百分比RAM的用法,但我不力獲得成功整體CPU使用率和在Linux的百分比內存(RAM)使用/ Ubuntu的

$ command for cpu usage 
4.85% 

$ command for memory usage 
15.15% 

OR

$ command for cpu and mamory usage 
cpu: 4.85% 
mem: 15.15% 

我該如何做到這一點?

+0

http://stackoverflow.com/questions/10585978/linux-command-for-percentage-of-memory-that -is-free – Kris

+1

[在Linux上如何獲得總體CPU使用率(例如57%)]的可能副本(http://stackoverflow.com/questions/9229333/how-to-get-overall-cpu-usage-eg- 57上的Linux) – Kris

回答

3

您可以使用procps軟件包中的top和/或vmstat。 使用vmstat -s來獲得您計算機上的RAM數量(可選),然後使用top的輸出來計算內存使用率百分比。

%Cpu(s): 3.8 us, 2.8 sy, 0.4 ni, 92.0 id, 1.0 wa, 0.0 hi, 0.0 si, 0.0 st 
KiB Mem : 24679620 total, 1705524 free, 7735748 used, 15238348 buff/cache 
KiB Swap:  0 total,  0 free,  0 used. 16161296 avail Mem 

您也可以相對較短的輸出做到這一點:

watch '/usr/bin/top -b | head -4 | tail -2'

相關問題