A Prometheus exporter for macOS hardware sensors, including temperature, voltage, current, power, battery, and fan metrics from the System Management Controller (SMC).
English | 简体中文
- Exports macOS hardware sensor metrics in Prometheus format
- Support for multiple sensor types:
- Temperature (°C)
- Voltage (V)
- Current (A)
- Power (W)
- Fan speed (RPM)
- Battery information
- Health check endpoint
- Configurable via CLI flags, config file, or environment variables
- Display sensor information directly in terminal (table, JSON, or ASCII format)
- macOS (tested on macOS 10.13+)
- Go 1.22+ (for building from source)
- Root/Administrator privileges may be required to access SMC sensors
# Add the tap
brew tap xykong/tap
# Install
brew install macos-sensor-exporter
# Start as a service (auto-start on boot)
brew services start macos-sensor-exporter
# Or run manually
macos-sensor-exporter startManage the service:
# Check service status
brew services list
# Stop the service
brew services stop macos-sensor-exporter
# Restart the service
brew services restart macos-sensor-exporter
# View logs
tail -f $(brew --prefix)/var/log/macos-sensor-exporter.loggit clone https://github.com/xykong/macos-sensor-exporter.git
cd macos-sensor-exporter
go build -o macos-sensor-exporter .go install github.com/xykong/macos-sensor-exporter@latestStart the exporter server on the default port (9101):
./macos-sensor-exporter startWith custom port and metrics path:
./macos-sensor-exporter start --port 8080 --pattern /custom-metricsWith verbose logging:
./macos-sensor-exporter start -vDisplay sensor information directly in the terminal:
# ASCII format (default)
./macos-sensor-exporter show
# Table format
./macos-sensor-exporter show -o table
# JSON format
./macos-sensor-exporter show -o jsonThe exporter can be configured using:
- Command-line flags (highest priority)
- Environment variables (with
VIPER_prefix) - Configuration file (lowest priority)
Create a .macos-sensor-exporter.yaml file in your home directory or current directory:
port: 9101
pattern: /metricsOr specify a custom config file location:
./macos-sensor-exporter start --config /path/to/config.yamlAdd the following to your prometheus.yml:
scrape_configs:
- job_name: 'macos-sensors'
static_configs:
- targets: ['localhost:9101']The exporter provides metrics in the following format:
sensor_<category>_<description>_<unit>{index="<number>"} <value>
Example metrics:
sensor_temperature_cpu_die_celsius 45.5
sensor_voltage_cpu_core_volts 1.2
sensor_power_cpu_total_watt 15.3
sensor_fans_speed_rpm{index="0"} 1800
sensor_battery_charge_amperes 2.5
- Temperature: CPU, GPU, and other component temperatures
- Voltage: CPU core, GPU, and system voltages
- Current: Battery and power supply current
- Power: CPU, GPU, and total system power consumption
- Fans: Fan speeds for all installed fans
- Battery: Battery status and metrics
/metrics- Prometheus metrics endpoint (default, configurable)/healthz- Health check endpoint (returns 200 OK)
make buildgo test ./..../macos-sensor-exporter start -vThe project structure:
.
├── main.go # Entry point
├── cmd/ # CLI commands
│ ├── root.go # Root command and config
│ ├── start.go # Start exporter server
│ └── show.go # Show sensor info
└── exporter/ # Prometheus exporter logic
└── exporter.go # Collector implementation
If you encounter permission errors accessing SMC sensors, try running with sudo:
sudo ./macos-sensor-exporter startEnsure your Mac supports SMC sensor access. Some virtualized or older Mac models may have limited sensor availability.
Check if the port is already in use:
lsof -i :9101Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE file for details.
This project uses:
- iSMC for SMC sensor access
- Prometheus client_golang for metrics export
- Cobra for CLI
- Viper for configuration management
- node_exporter - Prometheus exporter for hardware and OS metrics (Linux)
- iSMC - macOS SMC tool and library