A Prometheus exporter for monitoring battery metrics on a macOS system.
On your Prometheus server host:
- Create a virtual environment using python3.7 or higher
- Install the dependencies via
pip install -r requirements.txt
This exporter will only work on macOS 10.15 Catalina (macOS 11.xx Big Sur is not supported yet), due to the -json
option in system_profiler
not being available for the previous macOS releases.
On the macOS device, run the following command:
python3 mac_battery_exporter.py
Add the following to your prometheus.yml
:
scrape_configs:
- job_name: 'mac_battery_exporter'
static_configs:
- targets:
- mac_device_ip:8333
Metric name | Description |
---|---|
sppower_battery_cycle_count |
Cycle Count |
sppower_battery_fully_charged |
Fully Charged (1 or 0) |
sppower_battery_is_charging |
Charging (1 or 0) |
sppower_battery_current_capacity |
Charge Remaining (mAh) |
sppower_battery_max_capacity |
Full Charge Capacity (mAh) |
sppower_current_amperage |
Amperage (mA) |
sppower_current_voltage |
Voltage (mV) |
Pull requests are welcome!