[英]Linux - Displaying Memory Usage Live
我正在運行GNU-屏幕(4.03.01),因此我可以將多個終端合而為一,而且我正在尋找一種顯示內存實時狀態的好方法,以便進行諸如編譯,測試程序等操作。 ...我可以看到剩余了多少資源。
我知道性能監視器有“ TOP”……和其他類似的程序,但是我沒有在尋找整個活動進程列表等……我只想要我的內存統計信息的快照,例如每3個更新一次5秒。
感謝您抽出寶貴的時間來幫助我,非常感謝!
(出於可視化目的)
屏幕截圖:
您可以使用watch的組合,它重復指定的程序並顯示其輸出,而free則顯示當前的內存使用情況
watch free -m
free --help Usage: free [options] Options: -b, --bytes show output in bytes -k, --kilo show output in kilobytes -m, --mega show output in megabytes -g, --giga show output in gigabytes --tera show output in terabytes -h, --human show human-readable output --si use powers of 1000 not 1024 -l, --lohi show detailed low and high memory statistics -o, --old use old format (without -/+buffers/cache line) -t, --total show total for RAM + swap -s N, --seconds N repeat printing every N seconds -c N, --count N repeat printing N times, then exit --help display this help and exit -V, --version output version information and exit For more details see free(1).
watch --help Usage: watch [options] command Options: -b, --beep beep if command has a non-zero exit -c, --color interpret ANSI color sequences -d, --differences[=] highlight changes between updates -e, --errexit exit if command has a non-zero exit -g, --chgexit exit when output from command changes -n, --interval seconds to wait between updates -p, --precise attempt run command in precise intervals -t, --no-title turn off header -x, --exec pass command to exec instead of "sh -c" -h, --help display this help and exit -v, --version output version information and exit
您可以使用valgrind工具Massif ,但我沒有嘗試過,但這似乎是您想要的。
要使用massif,請安裝valgrind然后運行:
valgrind --tool=massif program argument1 argument2 ...
另一個快速的解決方案是這樣的腳本
while true; do
free -m
# any command for CPU stats - i didn't understand - what you really want to see, please clarify - just % of CPU usage ?
# i think this command should help you.
ps -A -o pcpu | tail -n+2 | paste -sd+ | bc
done
您可以做的另一件事是使用htop
。 它顯示內存使用情況,每個內核的CPU使用情況,並顯示每個進程使用的資源。 確實很整潔,但可能沒有其余答案那么詳細。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.