From ba8e082e64684bf3f1e0eecfe9afb0ea0ef6a0c9 Mon Sep 17 00:00:00 2001 From: Thor77 Date: Thu, 3 Nov 2016 22:40:57 +0100 Subject: [PATCH] Reconnect clients only for last log (online_dc) because doing it after every log would lead to insane onlinetimes and only the last log should have online clients, anyways. Fix #4 --- tsstats/log.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tsstats/log.py b/tsstats/log.py index fc37f65..2a6f0c2 100644 --- a/tsstats/log.py +++ b/tsstats/log.py @@ -29,7 +29,7 @@ TimedLog = namedtuple('TimedLog', ['path', 'timestamp']) logger = logging.getLogger('tsstats') -def parse_logs(log_glob, ident_map=None, *args, **kwargs): +def parse_logs(log_glob, ident_map=None, online_dc=True, *args, **kwargs): ''' parse logs from `log_glob` @@ -46,8 +46,15 @@ def parse_logs(log_glob, ident_map=None, *args, **kwargs): for virtualserver_id, logs in\ _bundle_logs(log_file for log_file in glob(log_glob)).items(): clients = Clients(ident_map) - for log in logs: - _parse_details(log.path, clients=clients, *args, **kwargs) + # keep last log out of the iteration for now + for log in logs[:-1]: + # don't reconnect connected clients for all logs except last one + # because that would lead to insane onlinetimes + _parse_details(log.path, clients=clients, online_dc=False, + *args, **kwargs) + # now parse details of last log with correct online_dc set + _parse_details(logs[-1].path, clients=clients, online_dc=online_dc, + *args, **kwargs) if len(clients) >= 1: vserver_clients[virtualserver_id] = clients return vserver_clients