proxtop icon indicating copy to clipboard operation
proxtop copied to clipboard

Drop 20% of readings because they are crap?

Open wdoekes opened this issue 7 years ago • 1 comments

def checking_foreach(data, item):
    """For some reason, the Proxmox API hands us crazy large values from
    time to time when we use the month-timeframe."""
    too_large = 0xffffffff  # 4 GiB/s..
    values = []
    valid, ignored = [], []
    # Take 80% of the center values only!
    for row in data:
        value = row.get(item)
        if value is not None:  # None if machine was down
            values.append(value)
#        if value is None:
#            pass
#        elif value <= too_large:
#            valid.append(value)
#        else:
#            ignored.append(value)
    values.sort()
    #for idx, value in enumerate(values):
    #    print(idx, value)
    fraction = len(values) / 10  # 10%
#    ignored = values[0:fraction] + values[-fraction:]
#    print(fraction, -fraction)
    valid = values[fraction:-fraction]  # 10%..90%
    return valid, ignored

wdoekes avatar Jul 03 '17 11:07 wdoekes

Sample set:

0 204.8
1 245.76
2 245.76
3 245.76
4 273.066666667
5 273.066666667
6 273.066666667
7 273.066666667

...

60 1365.33333333
61 1474.56
62 1501.86666667
63 1925.12
64 2621.44
65 3276.8
66 171827.2
67 2026209.28
68 3950390988.8
69 3.07445730611e+17

wdoekes avatar Jul 03 '17 11:07 wdoekes