From e0c20e72dd9e84e1cac5f02a8514f7d6cfd36760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20M=C3=A4der?= <maeder@phys.ethz.ch> Date: Tue, 10 Apr 2018 15:14:22 +0200 Subject: [PATCH] Finish skeleton logparser --- bin/deltalogparse.py | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/bin/deltalogparse.py b/bin/deltalogparse.py index 6707350..5b16f83 100755 --- a/bin/deltalogparse.py +++ b/bin/deltalogparse.py @@ -2,6 +2,7 @@ import sys import time +import datetime import re import pprint import lib_path @@ -68,22 +69,24 @@ def main(): connection.bind() - response = connection.search( - search_base=search_base, - search_filter=search_filter, - search_scope=search_scope, - attributes=attributes - ) + reqs_last_run = list() + req_start = datetime.datetime.utcnow().strftime('%Y%m%d%H%M%S.%fZ') while True: start_time = time.perf_counter() - req_start = None + + response = connection.search( + search_base=search_base, + search_filter=''.join(['(&', search_filter, '(reqStart>=', req_start, ')',')']), + search_scope=search_scope, + attributes=attributes + ) if response: - #for entry in connection.entries: - # print(entry.entry_dn) - # print(entry['reqStart']) for entry in connection.response: + if entry['attributes']['reqStart'][0] == req_start: + continue + req_start = entry['attributes']['reqStart'][0] req_type = entry['attributes']['reqType'][0] req_dn = entry['attributes']['reqDN'][0] @@ -107,15 +110,6 @@ def main(): if sleep_time > 0: time.sleep(sleep_time) - #else: - # time.sleep(update_every) - - response = connection.search( - search_base=search_base, - search_filter=search_filter, - search_scope=search_scope, - attributes=attributes - ) if __name__ == '__main__': -- GitLab