什么相当于 FreeBSD v8.1 上的 Linux 'free' 命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4093786/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 23:52:45  来源:igfitidea点击:

What is equivalent of Linux's 'free' command on FreeBSD v8.1

linuxmemoryfreebsdportingfree-command

提问by WilliamKF

What is equivalent of Linux's 'free' command on FreeBSD v8.1?

FreeBSD v8.1 上的 Linux 'free' 命令相当于什么?

I am calling 'free' from my application and reporting the results in my application's log file. What would be the replacement when porting to FreeBSD v8.1?

我从我的应用程序中调用“免费”并在我的应用程序日志文件中报告结果。移植到 FreeBSD v8.1 时,替代品是什么?

Here is a sample run of 'free' on Linux:

这是在 Linux 上运行“免费”的示例:

[centos4x32 ~] free
             total       used       free     shared    buffers     cached
Mem:        774452     733044      41408          0      98040     328880
-/+ buffers/cache:     306124     468328
Swap:      2031608        224    2031384

采纳答案by Ben Hymanson

  • vmstathas default output which is similar in nature and takes many options that give extremely detailed information, eg vmstat -m
  • swapinfowould cover the swap part
  • top -d1causes top to print one screen and exit, and the banner is very similar to free. Use top -d1 | head -n 7to see only the banner
  • vmstat具有本质上相似的默认输出,并采用许多提供极其详细信息的选项,例如 vmstat -m
  • swapinfo将涵盖交换部分
  • top -d1导致 top 打印一屏退出,banner 与free. 用于top -d1 | head -n 7仅查看横幅

回答by Brian Minton

vmstat -sgives some more human-readable or script-parseable information, including listing the page size. Otherwise, it gives output in numbef of pages. With no options, vmstatgives a brief summary.

vmstat -s提供了一些更易读或脚本可解析的信息,包括列出页面大小。否则,它会以 numbef 的页数给出输出。没有选项,vmstat给出一个简短的总结。

The vmstatcommand also exists on NetBSD.

vmstat命令也存在于 NetBSD 上。

回答by David Okwii

You can use this script.

您可以使用此脚本。

# fetch http://www.cyberciti.biz/files/scripts/freebsd-memory.pl.txt
# mv freebsd-memory.pl.txt /usr/local/bin/free
# chmod +x /usr/local/bin/free  

source: http://www.cyberciti.biz/faq/freebsd-command-to-get-ram-information/

来源:http: //www.cyberciti.biz/faq/freebsd-command-to-get-ram-information/

回答by miguelcm

Other option:

其他选择:

# vmstat fre

procs      memory      page                      faults         cpu
 r b w     avm    fre   flt  re  pi  po    fr  sr   in   sy   cs us sy id
 0 0 0  13475M    24M   689   1   2   0   344 394 14693 37734 60809  7 43 50

回答by Nan Xiao

Maybe freecolorcommand is a choice. Install it:

也许freecolor命令是一种选择。安装它:

# cd /usr/ports/sysutils/freecolor
# make install clean

Use it:

用它:

# freecolor
Physical  : [#################################..] 94%   (1907820/2018396)
Swap      : [###################################] 100%  (1048540/1048540)
# freecolor -m -o
             total       used       free     shared    buffers     cached
Mem:          1971        107       1863          0          0          0
Swap:         1023          0       1023

Please refer FreeBSD find out RAM size Including Total Amount of Free and Used Memory Size.

请参考FreeBSD 找出 RAM 大小,包括总可用和已用内存大小

回答by xsor

just use old good htop

只需使用旧的好htop

install htop

安装 htop

 pkg install htop

to run

跑步

htop