summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmonitor/josef_logreader.py59
-rw-r--r--monitor/monitor_conf.py17
2 files changed, 69 insertions, 7 deletions
diff --git a/monitor/josef_logreader.py b/monitor/josef_logreader.py
new file mode 100755
index 0000000..62edfff
--- /dev/null
+++ b/monitor/josef_logreader.py
@@ -0,0 +1,59 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+import sys
+import time
+import datetime
+import os
+
+from monitor_conf import *
+
+TIME_LEN = 21
+NEW_STH_STR = "STH updated"
+START_STR = "Starting monitor"
+
+def get_logs():
+ logs = []
+ for file in os.listdir("./" + OUTPUT_DIR):
+ if file.endswith(".log"):
+ logs.append(file)
+ return logs
+
+def get_age_from_line(line):
+ past = datetime.datetime.strptime(line[:20], '%Y-%m-%d, %H:%M:%S')
+ present = datetime.datetime.now()
+ return present - past
+
+def read_loglog(filename):
+ with open(OUTPUT_DIR + filename) as f:
+ content = f.readlines()
+ return content
+
+def print_log_stats(l):
+ print l
+ log = read_loglog(l)
+ rev_log = list(reversed(log))
+ last = rev_log[0]
+
+ # Stats from last STH update
+ for item in rev_log:
+ line = item[TIME_LEN:]
+ # if line[:len(START_STR)] == START_STR:
+ # break
+ if line[:len(NEW_STH_STR)] == NEW_STH_STR:
+ timestamp = datetime.datetime.strptime(line[-20:-1], '%Y-%m-%d %H:%M:%S')
+ age = datetime.datetime.now() - timestamp
+ size = line.split("Size: ")[1].split(",")[0]
+ # print line[:-1]
+ print "STH age: " + str(age)[:-7]
+ print "Size: " + size
+ break
+ # else:
+ # print "No STH update found in log."
+
+ print ""
+
+if __name__ == "__main__":
+ logs = get_logs()
+ for log in logs:
+ print_log_stats(log) \ No newline at end of file
diff --git a/monitor/monitor_conf.py b/monitor/monitor_conf.py
index 68f2c85..c6852a0 100644
--- a/monitor/monitor_conf.py
+++ b/monitor/monitor_conf.py
@@ -22,17 +22,17 @@ MONITORED_DOMAINS = [
"*.kth.se",
"*.nordu.net",
"*.sunet.se",
- # "mail.google.com",
- # "*.symantec.com",
- # "*.se",
+ "mail.google.com",
+ "*.symantec.com",
+ "*.se",
]
# CT logs and associated keys
ctlogs = [
- # {"name" : "pilot",
- # "url" : "https://ct.googleapis.com/pilot/",
- # "key" : "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfahLEimAoz2t01p3uMziiLOl/fHTDM0YDOhBRuiBARsV4UvxG2LdNgoIGLrtCzWE0J5APC2em4JlvR8EEEFMoA==",
- # "id" : "pLkJkLQYWBSHuxOizGdwCjw1mAT5G9+443fNDsgN3BA="},
+ {"name" : "pilot",
+ "url" : "https://ct.googleapis.com/pilot/",
+ "key" : "MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEfahLEimAoz2t01p3uMziiLOl/fHTDM0YDOhBRuiBARsV4UvxG2LdNgoIGLrtCzWE0J5APC2em4JlvR8EEEFMoA==",
+ "id" : "pLkJkLQYWBSHuxOizGdwCjw1mAT5G9+443fNDsgN3BA="},
{"name" : "plausible",
"url" : "https://plausible.ct.nordu.net/",
@@ -74,3 +74,6 @@ ctlogs = [
"key" : "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAolpIHxdSlTXLo1s6H1OCdpSj/4DyHDc8wLG9wVmLqy1lk9fz4ATVmm+/1iN2Nk8jmctUKK2MFUtlWXZBSpym97M7frGlSaQXUWyA3CqQUEuIJOmlEjKTBEiQAvpfDjCHjlV2Be4qTM6jamkJbiWtgnYPhJL6ONaGTiSPm7Byy57iaz/hbckldSOIoRhYBiMzeNoA0DiRZ9KmfSeXZ1rB8y8X5urSW+iBzf2SaOfzBvDpcoTuAaWx2DPazoOl28fP1hZ+kHUYvxbcMjttjauCFx+JII0dmuZNIwjfeG/GBb9frpSX219k1O4Wi6OEbHEr8at/XQ0y7gTikOxBn/s5wQIDAQAB",
"id" : "rDua7X+pZ0dXFZ5tfVdWcvnZgQCUHpve/+yhMTt1eC0="},
]
+
+
+