Compare commits

...

2 Commits

2 changed files with 14 additions and 8 deletions

View File

@ -139,9 +139,13 @@ class TimeSeries(Widget):
def v2y(v):
if self.yscale == "log":
return (1 - math.log(v / min_value)
/ math.log(max_value / min_value)
) * 200
try:
return (1 - math.log(max(v, min_value) / min_value)
/ math.log(max_value / min_value)
) * 200
except ValueError:
log.error(f"ValueError: v = {v}, min_value = {min_value}, max_value = {max_value}")
return 0
elif self.yscale == "linear":
return (1 - v/max_value) * 200
else:

View File

@ -4,6 +4,7 @@ import logging
import logging.config
import os
import socket
import statistics
import time
from ltsdb_json import LTS
@ -44,12 +45,13 @@ class DiskFullPredictor:
current_used_bytes = lts.data[-1][1]
current_usable_bytes = usable_lts.data[-1][1]
tuf = 1E9
for d in reversed(lts.data):
if d[1] < current_usable_bytes * 0.1:
for i in reversed(range(len(lts.data))):
m = statistics.mean(x[1] for x in lts.data[max(0, i - 2) : min(len(lts.data), i + 3)])
if m < current_usable_bytes * 0.1:
continue # for sanity
if current_used_bytes ** 2 / d[1] > current_usable_bytes:
log.info("d = %s, current_used_bytes = %s, current_usable_bytes = %s", d, current_used_bytes, current_usable_bytes)
tuf = now - d[0]
if current_used_bytes ** 2 / m > current_usable_bytes:
log.info("d = %s, current_used_bytes = %s, current_usable_bytes = %s", m, current_used_bytes, current_usable_bytes)
tuf = now - lts.data[i][0]
break
desc = {**lts.description,
"measure": "time_until_disk_full",