graphing optimized
This commit is contained in:
+17
-14
@@ -20,7 +20,7 @@ DS_NAMES = (
|
||||
"failed_services", "oom_kills",
|
||||
"free_root", "free_1", "free_2", "inode_root", "inode_1", "inode_2",
|
||||
"readonly_root", "readonly_1", "readonly_2",
|
||||
"storage_health",
|
||||
"health_root", "health_1", "health_2",
|
||||
)
|
||||
|
||||
|
||||
@@ -64,7 +64,8 @@ def create_rrd(path: Path) -> None:
|
||||
"DS:inode_1:GAUGE:180:0:100", "DS:inode_2:GAUGE:180:0:100",
|
||||
"DS:readonly_root:GAUGE:180:0:1", "DS:readonly_1:GAUGE:180:0:1",
|
||||
"DS:readonly_2:GAUGE:180:0:1",
|
||||
"DS:storage_health:GAUGE:180:0:10",
|
||||
"DS:health_root:GAUGE:180:0:10", "DS:health_1:GAUGE:180:0:10",
|
||||
"DS:health_2:GAUGE:180:0:10",
|
||||
]
|
||||
# 1-minute data for a day, 5-minute data for two weeks, hourly for a year.
|
||||
archives = [
|
||||
@@ -206,20 +207,18 @@ def disk_metrics(mountpoint: str) -> tuple[float, float, float | str, int]:
|
||||
|
||||
|
||||
def storage_health_score(
|
||||
storage: list[tuple[float, float, float | str, int]],
|
||||
storage: tuple[float, float, float | str, int],
|
||||
io_wait: float) -> float:
|
||||
"""Score current storage operability from 0 (unusable) to 10 (healthy)."""
|
||||
if any(read_only for _used, _free, _inodes, read_only in storage):
|
||||
"""Score one filesystem's operability from 0 (unusable) to 10 (healthy)."""
|
||||
used, _free, inodes, read_only = storage
|
||||
if read_only:
|
||||
return 0.0
|
||||
|
||||
score = 10.0
|
||||
for used, _free, inodes, _read_only in storage:
|
||||
# No penalty through 75%; decline linearly to zero at 100%.
|
||||
space_score = max(0.0, min(10.0, (100.0 - used) / 25.0 * 10.0))
|
||||
score = min(score, space_score)
|
||||
if isinstance(inodes, float):
|
||||
inode_score = max(0.0, min(10.0, (100.0 - inodes) / 25.0 * 10.0))
|
||||
score = min(score, inode_score)
|
||||
# No penalty through 75%; decline linearly to zero at 100%.
|
||||
score = max(0.0, min(10.0, (100.0 - used) / 25.0 * 10.0))
|
||||
if isinstance(inodes, float):
|
||||
inode_score = max(0.0, min(10.0, (100.0 - inodes) / 25.0 * 10.0))
|
||||
score = min(score, inode_score)
|
||||
|
||||
# I/O wait is workload-sensitive, so it can reduce the score by at most
|
||||
# three points: no penalty through 10%, maximum penalty at 50%.
|
||||
@@ -258,12 +257,16 @@ def collect(config: configparser.SectionProxy) -> list[float | int | str]:
|
||||
read_only: list[int | str] = [item[3] for item in storage]
|
||||
for values in (disks, free, inodes, read_only):
|
||||
values.extend(["U"] * (3 - len(values)))
|
||||
health: list[float | str] = [
|
||||
storage_health_score(item, cpu[3]) for item in storage
|
||||
]
|
||||
health.extend(["U"] * (3 - len(health)))
|
||||
return [
|
||||
*load, *cpu, *net, *disks, memory_percent(), uptime_days(),
|
||||
cpu_temperature(), throttle_state(),
|
||||
failed_service_count(), oom_kill_count(),
|
||||
*free, *inodes, *read_only,
|
||||
storage_health_score(storage, cpu[3]),
|
||||
*health,
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user