How to Check CPU Information and Usage Statistics on macOS Server via Command Line


2 views

On macOS Server, the system_profiler command provides comprehensive hardware information:

system_profiler SPHardwareDataType

Sample output would include:

Hardware Overview:
  Model Name: Mac Pro
  Model Identifier: MacPro7,1
  Processor Name: 28-Core Intel Xeon W
  Processor Speed: 2.5 GHz
  Number of Processors: 1
  Total Number of Cores: 28
  L2 Cache (per Core): 1 MB
  L3 Cache: 38.5 MB

The top command shows live CPU statistics:

top -o cpu -l 2 -n 5 -stats pid,command,cpu,threads

Key parameters:

  • -o cpu: Sort by CPU usage
  • -l 2: Run for 2 samples
  • -n 5: Show top 5 processes
  • -stats: Customize displayed columns

For more advanced monitoring, consider these options:

# 1. Install sysctl (built-in)
sysctl -n machdep.cpu.brand_string

# 2. Install htop (via Homebrew)
brew install htop
htop

# 3. Use iStats for Ruby-based monitoring
gem install iStats
istats cpu

Here's a Bash script to extract specific CPU details:

#!/bin/bash

# Get CPU model
cpu_model=$(sysctl -n machdep.cpu.brand_string)
core_count=$(sysctl -n hw.ncpu)
thread_count=$(sysctl -n hw.logicalcpu_max)

echo "CPU Model: $cpu_model"
echo "Physical Cores: $core_count"
echo "Logical Cores: $thread_count"

For server monitoring, temperature is crucial. Install osx-cpu-temp:

brew install osx-cpu-temp
osx-cpu-temp

Sample output: 63.2°C 145.8°F


When working with Mac OS X Server environments, Linux administrators often miss familiar tools like mpstat or the /proc/cpuinfo interface. Here's how to gather detailed CPU information using native macOS commands.

The simplest way to get CPU model information:

sysctl -n machdep.cpu.brand_string

Example output:

Intel(R) Xeon(R) CPU E5-2697 v2 @ 2.70GHz

To see all available CPU-related sysctl variables:

sysctl machdep.cpu

This will display:

machdep.cpu.core_count: 12
machdep.cpu.thread_count: 24
machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC ...
machdep.cpu.leaf7_features: RDWRFSGS TSC_THREAD_OFFSET BMI1 AVX2 SMEP BMI2 ...

For real-time CPU monitoring similar to Linux's mpstat:

top -l 1 -s 0 -n 0 | grep "CPU usage"

For continuous monitoring (1-second intervals):

vm_stat 1

Install additional monitoring tools via Homebrew:

brew install htop sysstat

Then use htop for interactive monitoring or sar for system activity reporting.

To check the processor architecture:

uname -m

For Intel Macs this returns x86_64, while Apple Silicon shows arm64.

Important for server performance monitoring:

sudo powermetrics --samplers cpu_power -n 1

This shows CPU performance limitations due to thermal conditions.