adfded temperature, failed services and disk health
This commit is contained in:
+45
-8
@@ -18,16 +18,47 @@ LOAD_COLORS = ["#FACC15", "#F59E0B", "#DC2626"] # bottom to top
|
||||
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) -> None:
|
||||
network_mixed: bool = False, thermal_mixed: bool = False,
|
||||
trouble_mixed: bool = False, storage_status: 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",
|
||||
"--watermark", "cheap-system-monitor"]
|
||||
if logarithmic:
|
||||
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):
|
||||
args += ["--lower-limit", "0", "--upper-limit", "10", "--rigid"]
|
||||
value_suffix = "%%" if unit == "%" else ""
|
||||
for index, (ds, label, cf) in enumerate(series):
|
||||
var = f"v{index}"
|
||||
if thermal_mixed and ds == "throttled":
|
||||
args += [f"DEF:{var}_raw={rrd}:{ds}:{cf}",
|
||||
f"CDEF:{var}={var}_raw,100,*",
|
||||
f"AREA:{var}#DC262640:{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 trouble_mixed and ds == "oom_kills":
|
||||
args += [f"DEF:{var}_raw={rrd}:{ds}:{cf}",
|
||||
f"CDEF:{var}={var}_raw,60,*",
|
||||
f"AREA:{var}#DC262680:{label}",
|
||||
f"GPRINT:{var}:LAST:Current\\:%8.2lf",
|
||||
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":
|
||||
@@ -69,17 +100,23 @@ 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),
|
||||
("cpu", "CPU usage", "%", [("cpu_user", "user", "AVERAGE"), ("cpu_system", "system", "AVERAGE"), ("cpu_nice", "nice", "AVERAGE")], False, True, False, False),
|
||||
("network", "Network throughput", "bytes/s", [("net_out", "sent", "AVERAGE"), ("net_in", "received", "AVERAGE")], False, False, False, True),
|
||||
("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),
|
||||
("uptime", "System uptime", "days", [("uptime", "uptime", "AVERAGE")], 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, 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", "0–10", [("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),
|
||||
]
|
||||
for period_name, start in PERIODS.items():
|
||||
for filename, title, unit, series, logarithmic, stacked, disk_memory, network_mixed in definitions:
|
||||
for filename, title, unit, series, logarithmic, stacked, disk_memory, network_mixed, thermal_mixed, trouble_mixed, storage_status in definitions:
|
||||
graph(output_dir / f"{filename}-{period_name}.png", rrd, start,
|
||||
f"{title} — {period_name}", unit, series, logarithmic,
|
||||
stacked, disk_memory, network_mixed)
|
||||
stacked, disk_memory, network_mixed, thermal_mixed,
|
||||
trouble_mixed, storage_status)
|
||||
page_files = {
|
||||
"3hours": "index.html",
|
||||
"1day": "1day.html",
|
||||
|
||||
Reference in New Issue
Block a user