bug fix
This commit is contained in:
parent
13514d1600
commit
6d405bb052
16
o_manager.py
16
o_manager.py
@ -88,7 +88,7 @@ class OManager:
|
|||||||
}
|
}
|
||||||
return state
|
return state
|
||||||
|
|
||||||
def get_stat(self, time_range=5, n_bins=200):
|
def get_stat(self, time_range=5, n_bins=60):
|
||||||
stat = []
|
stat = []
|
||||||
|
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
@ -100,9 +100,9 @@ class OManager:
|
|||||||
io_tas = TimeSeriesAccumulator(
|
io_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)
|
||||||
for line in io_stat:
|
for line in io_stat:
|
||||||
time, value = line.split(",")
|
time, value_down, value_up = line.split(",")
|
||||||
time = datetime.utcfromtimestamp(float(time))
|
time = datetime.utcfromtimestamp(float(time))
|
||||||
value = float(value)
|
value = float(value_down)
|
||||||
if first_line:
|
if first_line:
|
||||||
first_line = False
|
first_line = False
|
||||||
else:
|
else:
|
||||||
@ -124,6 +124,8 @@ class OManager:
|
|||||||
|
|
||||||
def ping_rate(x):
|
def ping_rate(x):
|
||||||
x = numpy.array(x)
|
x = numpy.array(x)
|
||||||
|
if len(x)==0:
|
||||||
|
return numpy.nan
|
||||||
return numpy.count_nonzero(x > 0)/len(x)
|
return numpy.count_nonzero(x > 0)/len(x)
|
||||||
|
|
||||||
stat.append({
|
stat.append({
|
||||||
@ -131,7 +133,13 @@ class OManager:
|
|||||||
"ping_mean": ping_tas.get_f(ping_mean),
|
"ping_mean": ping_tas.get_f(ping_mean),
|
||||||
"ping_rate": ping_tas.get_f(ping_rate)
|
"ping_rate": ping_tas.get_f(ping_rate)
|
||||||
})
|
})
|
||||||
return stat
|
if self.instances:
|
||||||
|
xs = [j.isoformat() for j in ping_tas.get_ts()]
|
||||||
|
return {
|
||||||
|
"time": xs,
|
||||||
|
"stat": stat
|
||||||
|
}
|
||||||
|
return {}
|
||||||
|
|
||||||
def generate_lb_cfg(self, load_balance_mode):
|
def generate_lb_cfg(self, load_balance_mode):
|
||||||
lb_cfg_fp = os.path.join(
|
lb_cfg_fp = os.path.join(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user