Retrieve CPU and Memory Information on FreeBSD

Server running slow and how to check CPU/Processor and RAM/Memory info on FreeBSD? There are couple of ways to retrieve the information, by dmesg or sysctl.

Check CPU/Processor Speed on FreeBSD

Get CPU info by sysctl;

shell> sysctl -a | egrep -i 'machine|model|ncpu'

hw.machine: i386
hw.model: Intel(R) Pentium(R) D CPU 3.00GHz
hw.ncpu: 2
hw.machine_arch: i386

Get CPU info by dmesg boot message;

shell> egrep -i cpu /var/run/dmesg.boot

CPU: Intel(R) Pentium(R) D CPU 3.00GHz (2998.50-MHz 686-class CPU)
FreeBSD/SMP: Multiprocessor System Detected: 2 CPUs
 cpu0 (BSP): APIC ID:  0
 cpu1 (AP): APIC ID:  1
cpu0:  on acpi0
acpi_perf0:  on cpu0
acpi_perf0:  on cpu0
cpu1:  on acpi0
acpi_perf1:  on cpu1
acpi_perf1:  on cpu1
SMP: AP CPU #1 Launched!

Check Total Memory/RAM on FreeBSD

Get Memory/RAM information from dmesg boot message;

shell> grep -i 'memory' /var/run/dmesg.boot 
real memory  = 1072107520 (1022 MB)
avail memory = 1039966208 (991 MB)