Created
March 22, 2021 18:30
-
-
Save juanfont/c057c3d590e155aa9efe2e2fed243f51 to your computer and use it in GitHub Desktop.
PiJuice Prometheus Exporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pijuice import PiJuice | |
from prometheus_client import start_http_server, Gauge | |
import time | |
pj = PiJuice(1, 0x14) | |
battery_current = Gauge('pijuice_battery_current', 'Battery current') | |
charge_level = Gauge('pijuice_charge_level', 'Charge level') | |
battery_temperature = Gauge( | |
'pijuice_battery_temperature', 'Battery temperature') | |
battery_voltage = Gauge('pijuice_battery_voltage', 'Battery voltage') | |
io_current = Gauge('pijuice_io_current', 'IO Current') | |
io_voltage = Gauge('pijuice_io_voltage', 'IO Voltage') | |
start_http_server(9222) | |
while True: | |
battery_current.set(pj.status.GetBatteryCurrent().get("data")) | |
charge_level.set(pj.status.GetChargeLevel().get("data")) | |
battery_temperature.set(pj.status.GetBatteryTemperature().get("data")) | |
battery_voltage.set(pj.status.GetBatteryVoltage().get("data")) | |
io_current.set(pj.status.GetIoCurrent().get("data")) | |
io_voltage.set(pj.status.GetIoVoltage().get("data")) | |
time.sleep(15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment