|
1 | 1 | import logging
|
2 | 2 | import time
|
| 3 | +from typing import Any |
3 | 4 |
|
4 | 5 | import requests
|
5 | 6 | from jsonrpcclient import Error, Ok, parse, request_hex
|
@@ -52,15 +53,15 @@ def __init__(
|
52 | 53 | "Referer": f"http://{self.box_addr}/index.html",
|
53 | 54 | }
|
54 | 55 |
|
55 |
| - def run_metrics_loop(self): |
| 56 | + def run_metrics_loop(self) -> None: |
56 | 57 | """Metrics fetching loop"""
|
57 | 58 |
|
58 | 59 | while True:
|
59 | 60 | logging.debug("Fetching metrics.")
|
60 | 61 | self.fetch_metrics()
|
61 | 62 | time.sleep(self.polling_interval_seconds)
|
62 | 63 |
|
63 |
| - def _box_api_request(self, method: str) -> dict: |
| 64 | + def _box_api_request(self, method: str) -> dict[str, Any]: |
64 | 65 | response = requests.post(
|
65 | 66 | self.url,
|
66 | 67 | json=request_hex(method),
|
@@ -129,14 +130,14 @@ def _read_usage_record(self) -> None:
|
129 | 130 | if value := results.get("HUseData"):
|
130 | 131 | self.total_transfer_this_month.set(value)
|
131 | 132 |
|
132 |
| - def fetch_metrics(self): |
| 133 | + def fetch_metrics(self) -> None: |
133 | 134 | """Fetch all relevant metrics."""
|
134 | 135 | self._read_network_info()
|
135 | 136 | self._read_system_status()
|
136 | 137 | self._read_usage_record()
|
137 | 138 |
|
138 | 139 |
|
139 |
| -def main(): |
| 140 | +def main() -> None: |
140 | 141 | """Main entry point for the exporter"""
|
141 | 142 | logging.info("Linkhub Prometheus Exporter, version %s", __version__)
|
142 | 143 |
|
|
0 commit comments