FreeBSD Get CPU & Memory Information

beastieTo get information about CPU and Memory under FreeBSD use the following commands:

Getting CPU information:
From dmesg:

$ dmesg | grep CPU

Or

$ grep CPU /var/run/dmesg.boot | less

Using sysctl:
CPU model:

$ sysctl hw.model

CPU clock rate:

$ sysctl hw.clockrate

No of cpus:

$ sysctl hw.ncpu

Get all information:

$ sysctl -a | grep -i cpu | less

Getting memory information:
From dmesg:

$ dmesg | grep memory

Or

$ grep memory /var/run/dmesg.boot

Using sysctl:

$ sysctl -a | grep mem | less


FreeBSD find out memory usage

Download perl script which is written by Ralf S. Engelschall:

$ wget http://people.freebsd.org/~rse/dist/freebsd-memory -O free
$ chmod +x free
$ sudo mv free /usr/local/bin/
$ free

Output

SYSTEM MEMORY INFORMATION:
mem_wire:          55160832 (     52MB) [ 22%] Wired: disabled for paging out
mem_active:  +     33361920 (     31MB) [ 13%] Active: recently referenced
mem_inactive:+    140701696 (    134MB) [ 57%] Inactive: recently not referenced
mem_cache:   +     15224832 (     14MB) [  6%] Cached: almost avail. for allocation
mem_free:    +      1150976 (      1MB) [  0%] Free: fully available for allocation
mem_gap_vm:  +       663552 (      0MB) [  0%] Memory gap: UNKNOWN
-------------- ------------ ----------- ------
mem_all:     =    246263808 (    234MB) [100%] Total real memory managed
mem_gap_sys: +      4841472 (      4MB)        Memory gap: Kernel?!
-------------- ------------ -----------
mem_phys:    =    251105280 (    239MB)        Total real memory available
mem_gap_hw:  +     17330176 (     16MB)        Memory gap: Segment Mappings?!
-------------- ------------ -----------
mem_hw:      =    268435456 (    256MB)        Total real memory installed

SYSTEM MEMORY SUMMARY:
mem_used:         111357952 (    106MB) [ 41%] Logically used memory
mem_avail:   +    157077504 (    149MB) [ 58%] Logically available memory
-------------- ------------ ----------- ------
mem_total:   =    268435456 (    256MB) [100%] Logically total memory

Linux like free command for FreeBSD

Freecolor is a free replacement that displays free memory graphically as a bargraph. It supports the same options as free. Install freecolor, enter:

# pkg_add -r freecolor

To see memory details, enter:

# freecolor -m

Output

Physical  : [#######################............] 67% (162/239)
Swap      : [##################################.] 99% (599/600)
# freecolor -m -o

Output:

             total       used       free     shared    buffers     cached
Mem:           239         77        162          0          0          0
Swap:          600          0        599