[英]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.