fix bug
This commit is contained in:
parent
d914f15957
commit
02bfc93351
@ -113,7 +113,7 @@ class OManager:
|
||||
prev_value = value
|
||||
ping_stat = i["op"].get_ping_stat(lines=lines)
|
||||
ping_tas = TimeSeriesAccumulator(
|
||||
start_time=now-timedelta(minutes=time_range), end_time=now, n_bins=n_bins)
|
||||
start_time=now-timedelta(minutes=time_range), end_time=now, n_bins=n_bins, alignment=self.monitor_interval)
|
||||
for line in ping_stat:
|
||||
time, value = line.split(",")
|
||||
time = datetime.utcfromtimestamp(float(time))
|
||||
|
||||
@ -23,7 +23,7 @@ class TimeSeriesAccumulator:
|
||||
|
||||
def add(self, time, value):
|
||||
timestamp = time.replace(tzinfo=timezone.utc).timestamp()
|
||||
if time < self.start_time or time > self.end_time:
|
||||
if timestamp < self.start_timestamp or timestamp > self.end_timestamp:
|
||||
return
|
||||
idx = int((timestamp - self.start_timestamp)/self.bin_time)
|
||||
self.data[idx].append(value)
|
||||
@ -46,7 +46,7 @@ class TimeSeriesAccumulator:
|
||||
|
||||
if __name__ == "__main__":
|
||||
tsa = TimeSeriesAccumulator(start_time=datetime(
|
||||
2020, 7, 27, 23, 0, 0), end_time=datetime(2020, 7, 28, 0, 0, 0), n_bins=2)
|
||||
2020, 7, 27, 23, 0, 33), end_time=datetime(2020, 7, 28, 0, 0, 43), n_bins=2, alignment=5)
|
||||
tsa.add(datetime(2020, 7, 27, 23, 15, 0), 1)
|
||||
tsa.add(datetime(2020, 7, 27, 23, 45, 0), 2)
|
||||
tsa.add(datetime(2020, 7, 27, 22, 45, 0), 3)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user