FreeBSD找出RAM大小,包括可用内存和已用内存的总量
时间:2020-01-09 10:38:29 来源:igfitidea点击:
如何找到FreeBSD服务器中安装的RAM大小或内存大小?
如何在由FreeBSD驱动的系统中显示可用内存和已用内存量?
我如何知道FreeBSD 10或11服务器上安装了多少RAM?
要显示系统中可用和可用的物理内存和交换内存的总量,以及内核使用的缓冲区,您需要安装特殊的脚本或软件包。
大多数FreeBSD用户使用sysctal命令来获取所有数据。
有一个perl脚本可以自动执行所有操作并在屏幕上显示结果。
使用sysctl命令找出FreeBSD上安装了多少RAM。
输入以下命令:
$ sysctl hw.physmem $ sysctl hw | egrep 'hw.(phys|user|real)'
或者
$ grep memory /var/run/dmesg.boot
关于RAM大小和信息的FreeBSD命令
该脚本通过通用sysctl接口查询系统。
sysctl实用程序检索内核状态,并允许具有适当特权的进程设置内核状态。
您必须在FreeBSD上安装了perl。
首先,下载由Ralf S. Engelschall编写的Perl脚本:
$ fetch http://www.theitroad.local/files/scripts/freebsd-memory.pl.txt $ sudo mv freebsd-memory.pl.txt /usr/local/bin/free $ sudo chmod +x /usr/local/bin/free
确保在您的系统上安装了perl("哪个perl")。
要显示或列出系统内存使用总量,请执行:
$ free
输出示例:
SYSTEM MEMORY INFORMATION: mem_wire: 25341952 ( 24MB) [ 9%] Wired: disabled for paging out mem_active: + 47529984 ( 45MB) [ 18%] Active: recently referenced mem_inactive:+ 15605760 ( 14MB) [ 6%] Inactive: recently not referenced mem_cache: + 16384 ( 0MB) [ 0%] Cached: almost avail. for allocation mem_free: + 165556224 ( 157MB) [ 65%] Free: fully available for allocation mem_gap_vm: + 389120 ( 0MB) [ 0%] Memory gap: UNKNOWN -------------- ------------ ----------- ----- mem_all: = 254439424 ( 242MB) [100%] Total real memory managed mem_gap_sys: + 4988928 ( 4MB) Memory gap: Kernel?! -------------- ------------ ---------- mem_phys: = 259428352 ( 247MB) Total real memory available mem_gap_hw: + 9007104 ( 8MB) Memory gap: Segment Mappings?! -------------- ------------ ---------- mem_hw: = 268435456 ( 256MB) Total real memory installed SYSTEM MEMORY SUMMARY: mem_used: 87257088 ( 83MB) [ 32%] Logically used memory mem_avail: + 181178368 ( 172MB) [ 67%] Logically available memory -------------- ------------ ----------- ----- mem_total: = 268435456 ( 256MB) [100%] Logically total memory
您可以避免使用基于Perl的代码,并使用标准的sh shell通过freebsd-memory.sh脚本获取相同的信息:
$ fetch https://raw.githubusercontent.com/ocochard/myscripts/master/FreeBSD/freebsd-memory.sh ## or use curl command ## ## $ curl -O https://raw.githubusercontent.com/ocochard/myscripts/master/FreeBSD/freebsd-memory.sh $ sh freebsd-memory.sh
我基于FreeBSD的家庭路由器的输出示例:
SYSTEM MEMORY INFORMATION: mem_wire: 70152192 ( 66MB) [ 14%] Wired: disabled for paging out mem_active: + 44515328 ( 42MB) [ 9%] Active: recently referenced mem_inactive:+ 333316096 ( 317MB) [ 67%] Inactive: recently not referenced mem_cache: + 798720 ( 0MB) [ 0%] Cached: almost avail. for allocation mem_free: + 44724224 ( 42MB) [ 9%] Free: fully available for allocation mem_gap_vm: + -45056 ( 0MB) [ 0%] Memory gap: UNKNOWN ______________ ____________ ___________ ______ mem_all: = 493461504 ( 470MB) [100%] Total real memory managed mem_gap_sys: + 9297920 ( 8MB) Memory gap: Kernel?! ______________ ____________ ___________ mem_phys: = 502759424 ( 479MB) Total real memory available mem_gap_hw: + 34111488 ( 32MB) Memory gap: Segment Mappings?! ______________ ____________ ___________ mem_hw: = 536870912 ( 512MB) Total real memory installed SYSTEM MEMORY SUMMARY: mem_used: 158031872 ( 150MB) [ 29%] Logically used memory mem_avail: + 378839040 ( 361MB) [ 70%] Logically available memory ______________ ____________ __________ _______ mem_total: = 536870912 ( 512MB) [100%] Logically total memory
Linux对我的FreeBSD服务器来说像是免费命令
Freecolor是一种免费的替代产品,它以条形图的形式显示可用内存。
它支持与免费相同的选项。
安装freecolor,执行:
# cd /usr/ports/sysutils/freecolor # make install clean
或者
# pkg install freecolor
要查看内存详细信息,请执行:
$ freecolor -m -o
输出示例:
total used free shared buffers cached Mem: 4082 825 3256 0 0 117 Swap: 2048 0 2047
$ freecolor -t -m -o
输出示例:
total used free shared buffers cached Mem: 4082 825 3256 0 0 117 Swap: 2048 0 2047 Total: 6130 = ( 826 (used) + 5421 (free))
选项如下:
-b Display the amount of memory in bytes. -k Display the amount of memory in kilobytes. This is the default. -m Display the amount of memory in megabytes. -o Display the output in old format, the only difference being this option will disable the display of the "buffer adjusted" line. -s Continuously display the result delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times. -t Display a line showing the column totals. -V Display version information.
使用top命令
top显示和更新有关顶部cpu进程的信息,包括"物理内存统计信息",如下所示(来自top(1)手册页):
- Active:活跃的字节数。
- Inact:无效的字节数。
- " Wired":连线的字节数,包括BIO级缓存的文件数据页。
- Cache:可用于立即重新分配的干净字节缓存数据的数量。
- " Buf":用于BIO级磁盘缓存的字节数。
- Free:可用字节数。
$ top
使用top命令查看内存使用情况。