Search for global minimum if start of timeseries is unusable

This commit is contained in:
Peter J. Holzer 2024-09-07 14:36:16 +02:00
parent c462ca4d80
commit 001d03790d
1 changed files with 21 additions and 8 deletions

View File

@ -55,14 +55,27 @@ class DiskFullPredictor:
tuf = now - lts.data[i][0] tuf = now - lts.data[i][0]
break break
else: else:
# XXX - this is probably a range, so maybe we should use some kind # Try always use the minimum of a range.
# of average. It might also be zero, so maybe we have to search for # We prefer the first datapoint
# the first non-zero value? For now keep it simple. first_used_bytes = lts.data[0][2] if len(lts.data[0]) >= 4 else lts.data[0][1]
first_used_bytes = lts.data[0][1] # But if that's not useable we search the whole timeseries for the
historic_growth = current_used_bytes / first_used_bytes # minimum
future_growth = current_usable_bytes / current_used_bytes if first_used_bytes >= current_used_bytes:
tuf = math.log(future_growth) / math.log(historic_growth) * (now - lts.data[0][0]) first_used_bytes = current_used_bytes
tuf = max(tuf, now - lts.data[0][0]) first_i = None
for i in range(len(lts.data)):
used_bytes = lts.data[i][2] if len(lts.data[i]) >= 4 else lts.data[i][1]
if used_bytes < first_used_bytes:
first_used_bytes = used_bytes
first_i = i
else:
first_i = 0
if first_i is not None:
historic_growth = current_used_bytes / first_used_bytes
future_growth = current_usable_bytes / current_used_bytes
tuf = math.log(future_growth) / math.log(historic_growth) * (now - lts.data[first_i][0])
tuf = max(tuf, now - lts.data[first_i][0])
desc = {**lts.description, desc = {**lts.description,
"measure": "time_until_disk_full", "measure": "time_until_disk_full",
"node": node, "node": node,