config graphs to show

This commit is contained in:
2026-08-12 14:07:50 +02:00
parent 25966a1213
commit d64c14abfe
3 changed files with 40 additions and 2 deletions
+22 -1
View File
@@ -13,6 +13,10 @@ import subprocess
PERIODS = {"3hours": "3h", "1day": "1d", "2weeks": "2w", "1year": "1y"}
COLORS = ["#2563EB", "#DC2626", "#16A34A", "#9333EA"]
LOAD_COLORS = ["#FACC15", "#F59E0B", "#DC2626"] # bottom to top
DEFAULT_GRAPHS = (
"load", "cpu", "thermal", "trouble", "network", "disk",
"storage-health", "uptime",
)
def graph(output: Path, rrd: Path, start: str, title: str, unit: str,
@@ -107,7 +111,7 @@ def main() -> None:
mounts = [item.strip() for item in config["mountpoints"].split(",") if item.strip()]
if not mounts or mounts[0] != "/":
mounts.insert(0, "/")
definitions = [
all_definitions = [
("load", "Processor load", "load", [("load15", "15 minutes", "AVERAGE"), ("load5", "5 minutes", "AVERAGE"), ("load1", "1 minute", "AVERAGE")], False, True, False, False, False, False),
("cpu", "CPU usage", "%", [("cpu_user", "user", "AVERAGE"), ("cpu_system", "system", "AVERAGE"), ("cpu_nice", "nice", "AVERAGE"), ("io_wait", "I/O wait", "AVERAGE")], False, True, False, False, False, False),
("thermal", "CPU temperature and throttling", "°C", [("temperature", "temperature", "AVERAGE"), ("throttled", "throttled", "MAX")], False, False, False, False, True, False),
@@ -117,6 +121,23 @@ def main() -> None:
("storage-health", "Storage operational health", "010", [(f"health_{'root' if i == 0 else i}", mount, "MIN") for i, mount in enumerate(mounts)], False, False, False, False, False, False),
("uptime", "System uptime", "days", [("uptime", "uptime", "AVERAGE")], False, False, False, False, False, False),
]
configured_graphs = [
item.strip()
for item in config.get("graphs", ",".join(DEFAULT_GRAPHS)).split(",")
if item.strip()
]
if not configured_graphs:
raise SystemExit("At least one graph must be configured in 'graphs'")
definitions_by_name = {definition[0]: definition for definition in all_definitions}
unknown = [name for name in configured_graphs if name not in definitions_by_name]
if unknown:
available = ", ".join(DEFAULT_GRAPHS)
raise SystemExit(
f"Unknown graph name(s): {', '.join(unknown)}. Available: {available}"
)
if len(configured_graphs) != len(set(configured_graphs)):
raise SystemExit("Graph names in 'graphs' must not be repeated")
definitions = [definitions_by_name[name] for name in configured_graphs]
for period_name, start in PERIODS.items():
for filename, title, unit, series, logarithmic, stacked, disk_memory, network_mixed, thermal_mixed, trouble_mixed in definitions:
graph(output_dir / f"{filename}-{period_name}.png", rrd, start,