ugpio plugins

This commit is contained in:
Devaev Maxim
2020-09-06 08:47:43 +03:00
parent e8bd1e2648
commit a6dac4bd84
18 changed files with 321 additions and 75 deletions

View File

@@ -54,13 +54,18 @@ class ExportApi:
self.__user_gpio.get_state(),
])
rows: List[str] = []
self.__append_prometheus_rows(rows, atx_state["enabled"], "pikvm_atx_enabled")
self.__append_prometheus_rows(rows, atx_state["leds"]["power"], "pikvm_atx_power")
for mode in ["input", "output"]:
for (channel, gch) in gpio_state[f"{mode}s"].items():
self.__append_prometheus_rows(rows, gch["state"], f"pikvm_gpio_input_{channel}")
for (channel, ch_state) in gpio_state[f"{mode}s"].items():
for key in ["online", "state"]:
self.__append_prometheus_rows(rows, ch_state["state"], f"pikvm_gpio_{mode}_{key}_{channel}")
if hw_state is not None:
self.__append_prometheus_rows(rows, hw_state["health"], "pikvm_hw")
return Response(text="\n".join(rows))
def __append_prometheus_rows(self, rows: List[str], value: Any, path: str) -> None: