Smooth out old data to avoid false positives in disk full prediction
This commit is contained in:
parent
a95ba6c51f
commit
2e8641ad18
|
@ -4,6 +4,7 @@ import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
import os
|
import os
|
||||||
import socket
|
import socket
|
||||||
|
import statistics
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from ltsdb_json import LTS
|
from ltsdb_json import LTS
|
||||||
|
@ -44,12 +45,13 @@ class DiskFullPredictor:
|
||||||
current_used_bytes = lts.data[-1][1]
|
current_used_bytes = lts.data[-1][1]
|
||||||
current_usable_bytes = usable_lts.data[-1][1]
|
current_usable_bytes = usable_lts.data[-1][1]
|
||||||
tuf = 1E9
|
tuf = 1E9
|
||||||
for d in reversed(lts.data):
|
for i in reversed(range(len(lts.data))):
|
||||||
if d[1] < current_usable_bytes * 0.1:
|
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
|
continue # for sanity
|
||||||
if current_used_bytes ** 2 / d[1] > current_usable_bytes:
|
if current_used_bytes ** 2 / m > current_usable_bytes:
|
||||||
log.info("d = %s, current_used_bytes = %s, current_usable_bytes = %s", d, current_used_bytes, current_usable_bytes)
|
log.info("d = %s, current_used_bytes = %s, current_usable_bytes = %s", m, current_used_bytes, current_usable_bytes)
|
||||||
tuf = now - d[0]
|
tuf = now - lts.data[i][0]
|
||||||
break
|
break
|
||||||
desc = {**lts.description,
|
desc = {**lts.description,
|
||||||
"measure": "time_until_disk_full",
|
"measure": "time_until_disk_full",
|
||||||
|
|
Loading…
Reference in New Issue