diff options
author | Josef Gustafsson <josef.gson@gmail.com> | 2015-09-14 10:19:20 +0200 |
---|---|---|
committer | Josef Gustafsson <josef.gson@gmail.com> | 2015-09-14 10:19:20 +0200 |
commit | bff0b6df3a971ad69fe1cfc4d5853e186946debe (patch) | |
tree | dbd54abf77a5ff388581bdccdfc83be47e8b252d /monitor/josef_reader.py | |
parent | 1bb76ff1c99c3064ee2dfe2a5bfbde7d7796c726 (diff) |
counting not yet valid cers separately
Diffstat (limited to 'monitor/josef_reader.py')
-rwxr-xr-x | monitor/josef_reader.py | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/monitor/josef_reader.py b/monitor/josef_reader.py index c5755f1..8a927d8 100755 --- a/monitor/josef_reader.py +++ b/monitor/josef_reader.py @@ -15,7 +15,7 @@ import ast parser = argparse.ArgumentParser(description="") parser.add_argument('--domain', default=None, help="RTFM") parser.add_argument('--log', default=None, help="RTFM") -parser.add_argument('--exclude-expired', action='store_true', help="RTFM") +parser.add_argument('--exclude-invalid', action='store_true', help="RTFM") args = parser.parse_args() @@ -38,6 +38,8 @@ else: cur_time = dt.now() count_valid = 0 +count_expired = 0 +count_not_yet_valid = 0 count_all = 0 for item in raw: # print item + '}', type(item) @@ -58,35 +60,45 @@ for item in raw: success = False if cur_time > not_after_time: + valid = False expired = True elif cur_time < not_before_time: - expired = True + valid = False + expired = False else: expired = False + valid = True # Exclude expired - if args.exclude_expired and expired: + if args.exclude_invalid and not valid: success = False # Set count matches if success: count_all += 1 - if not expired: + if valid: count_valid += 1 + elif expired: + count_expired += 1 + else: + count_not_yet_valid += 1 # Print matching if success: s = entry["subject"].split("CN=")[1] + \ " certified by " + entry["issuer"].split("CN=")[1] + \ " (" + entry["log"] + ") " - if expired: - print "(NOT VALID) " + s - else: + if valid: print "(VALID) " + s + else: + print "(NOT VALID) " + s -print str(count_all) + " matches found." +print str(count_all) + " matches found. " \ ++ str(count_valid) + " valid, " \ ++ str(count_expired) + " expired and " \ ++ str(count_not_yet_valid) + " not yet valid." # print res |