From 227087284b9d061bce099f306e62a14631898402 Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Wed, 5 Sep 2018 21:41:33 -0300 Subject: [PATCH] blueprints.api: use downtime in milliseconds, not seconds This was giving way too optimistic availability rates. --- elstat/blueprints/api.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/elstat/blueprints/api.py b/elstat/blueprints/api.py index 16fd91e..9e7bbed 100644 --- a/elstat/blueprints/api.py +++ b/elstat/blueprints/api.py @@ -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)