graphing optimized

This commit is contained in:
2026-08-12 08:14:38 +02:00
parent 177c7479b6
commit 0fd16034d9
3 changed files with 41 additions and 49 deletions
+12 -24
View File
@@ -19,7 +19,7 @@ def graph(output: Path, rrd: Path, start: str, title: str, unit: str,
series: list[tuple[str, str, str]], logarithmic: bool = False,
stacked: bool = False, disk_memory: bool = False,
network_mixed: bool = False, thermal_mixed: bool = False,
trouble_mixed: bool = False, storage_status: bool = False) -> None:
trouble_mixed: bool = False) -> None:
args = ["rrdtool", "graph", str(output), "--start", f"end-{start}",
"--end", "now", "--width", "900", "--height", "260",
"--title", title, "--vertical-label", unit, "--slope-mode",
@@ -28,9 +28,7 @@ def graph(output: Path, rrd: Path, start: str, title: str, unit: str,
args += ["--logarithmic", "--lower-limit", "1"]
if thermal_mixed:
args += ["--lower-limit", "0", "--upper-limit", "100", "--rigid"]
if storage_status:
args += ["--lower-limit", "0", "--upper-limit", "100", "--rigid"]
if any(ds == "storage_health" for ds, _label, _cf in series):
if any(ds.startswith("health_") for ds, _label, _cf in series):
args += ["--lower-limit", "0", "--upper-limit", "10", "--rigid"]
value_suffix = "%%" if unit == "%" else ""
for index, (ds, label, cf) in enumerate(series):
@@ -51,14 +49,6 @@ def graph(output: Path, rrd: Path, start: str, title: str, unit: str,
f"GPRINT:{var}:AVERAGE:Average\\:%8.2lf",
f"GPRINT:{var}:MAX:Maximum\\:%8.2lf\\n"]
continue
if storage_status and ds.startswith("readonly_"):
args += [f"DEF:{var}_raw={rrd}:{ds}:{cf}",
f"CDEF:{var}={var}_raw,100,*",
f"LINE2:{var}{COLORS[index % len(COLORS)]}:{label}",
f"GPRINT:{var}_raw:LAST:Current\\:%8.0lf",
f"GPRINT:{var}_raw:AVERAGE:Average\\:%8.2lf",
f"GPRINT:{var}_raw:MAX:Maximum\\:%8.0lf\\n"]
continue
if network_mixed and ds == "net_out":
drawing = f"AREA:{var}#86EFAC:{label}"
elif network_mixed and ds == "net_in":
@@ -100,23 +90,21 @@ def main() -> None:
if not mounts or mounts[0] != "/":
mounts.insert(0, "/")
definitions = [
("load", "Processor load", "load", [("load15", "15 minutes", "AVERAGE"), ("load5", "5 minutes", "AVERAGE"), ("load1", "1 minute", "AVERAGE")], False, True, False, 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, False),
("thermal", "CPU temperature and throttling", "°C", [("temperature", "temperature", "AVERAGE"), ("throttled", "throttled", "MAX")], False, False, False, False, True, False, False),
("trouble", "Failed services and OOM kills", "count", [("failed_services", "failed services", "MAX"), ("oom_kills", "OOM kills/min", "MAX")], False, False, False, False, False, True, False),
("network", "Network throughput", "bytes/s", [("net_out", "sent", "AVERAGE"), ("net_in", "received", "AVERAGE")], False, False, False, True, False, False, False),
("disk", "Disk and memory usage", "%", [(f"disk_{'root' if i == 0 else i}", mount, "AVERAGE") for i, mount in enumerate(mounts)] + [("memory", "memory", "AVERAGE")], False, False, True, False, False, False, False),
("disk-free", "Available filesystem space", "GiB", [(f"free_{'root' if i == 0 else i}", mount, "AVERAGE") for i, mount in enumerate(mounts)], False, False, False, False, False, False, False),
("storage-status", "Inode usage and read-only filesystems", "%", [(f"inode_{'root' if i == 0 else i}", f"{mount} inodes", "MAX") for i, mount in enumerate(mounts)] + [(f"readonly_{'root' if i == 0 else i}", f"{mount} read-only", "MAX") for i, mount in enumerate(mounts)], False, False, False, False, False, False, True),
("storage-health", "Storage operational health", "010", [("storage_health", "health score", "MIN")], False, False, False, False, False, False, False),
("uptime", "System uptime", "days", [("uptime", "uptime", "AVERAGE")], False, False, False, False, False, False, False),
("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),
("trouble", "Failed services and OOM kills", "count", [("failed_services", "failed services", "MAX"), ("oom_kills", "OOM kills/min", "MAX")], False, False, False, False, False, True),
("network", "Network throughput", "bytes/s", [("net_out", "sent", "AVERAGE"), ("net_in", "received", "AVERAGE")], False, False, False, True, False, False),
("disk", "Disk and memory usage", "%", [(f"disk_{'root' if i == 0 else i}", mount, "AVERAGE") for i, mount in enumerate(mounts)] + [("memory", "memory", "AVERAGE")], False, False, True, False, False, False),
("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),
]
for period_name, start in PERIODS.items():
for filename, title, unit, series, logarithmic, stacked, disk_memory, network_mixed, thermal_mixed, trouble_mixed, storage_status in definitions:
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,
f"{title}{period_name}", unit, series, logarithmic,
stacked, disk_memory, network_mixed, thermal_mixed,
trouble_mixed, storage_status)
trouble_mixed)
page_files = {
"3hours": "index.html",
"1day": "1day.html",