blueprints.api: use downtime in milliseconds, not seconds

This was giving way too optimistic availability rates.
This commit is contained in:
Luna Mendes 2018-09-05 21:41:33 -03:00
parent 93630f64ef
commit 227087284b
1 changed files with 2 additions and 4 deletions

View File

@ -52,8 +52,6 @@ def get_graphs(manager):
def _raw_uptime(cur, service_name: str, worker, time_period: int) -> str:
"""Calculate uptime for a service given a timeframe."""
# get total period of the last 24 hours
max_tstamp = time.time() * 1000
min_tstamp = max_tstamp - time_period
@ -68,8 +66,8 @@ def _raw_uptime(cur, service_name: str, worker, time_period: int) -> str:
row = cur.fetchone()
down_hits = row[0]
# total downtime in seconds
downtime = down_hits * worker.service['poll']
# total downtime in milliseconds
downtime = down_hits * worker.service['poll'] * 1000
# calculate total downtime in percentage
percent = Decimal(downtime) / Decimal(t_period)