summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xmonitor/josef_logreader.py15
-rwxr-xr-xmonitor/josef_monitor.py34
-rw-r--r--monitor/monitor_conf.py2
3 files changed, 28 insertions, 23 deletions
diff --git a/monitor/josef_logreader.py b/monitor/josef_logreader.py
index 622674d..05ee969 100755
--- a/monitor/josef_logreader.py
+++ b/monitor/josef_logreader.py
@@ -37,8 +37,8 @@ def print_log_stats(l):
# 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(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.utcnow() - timestamp
@@ -58,6 +58,7 @@ def print_average_age(l):
prev_timestamp = None
ages = []
+ delays = []
for item in rev_log:
line = item[TIME_LEN:]
if line[:len(START_STR)] == START_STR:
@@ -65,13 +66,17 @@ def print_average_age(l):
prev_timestamp = None # Don't count over restarts
if line[:len(NEW_STH_STR)] == NEW_STH_STR:
timestamp = datetime.datetime.strptime(line[-20:-1], '%Y-%m-%d %H:%M:%S')
+ time_seen = datetime.datetime.strptime(item[:TIME_LEN -1], '%Y-%m-%d %H:%M:%S')
+ delays.append(time_seen - timestamp)
if prev_timestamp is not None:
ages.append(prev_timestamp - timestamp)
prev_timestamp = timestamp
- if len(ages) == 0:
- print "No timedeltas found.."
- else:
+ if not len(delays) == 0:
+ average_timedelta = sum(delays, datetime.timedelta(0)) / len(delays)
+ print "Average publish delay: " + str(average_timedelta) + " (" + str(len(delays)) + " values)"
+
+ if not len(ages) == 0:
average_timedelta = sum(ages, datetime.timedelta(0)) / len(ages)
print "Average update time: " + str(average_timedelta) + " (" + str(len(ages)) + " values)"
diff --git a/monitor/josef_monitor.py b/monitor/josef_monitor.py
index 6c189ca..a32cf7d 100755
--- a/monitor/josef_monitor.py
+++ b/monitor/josef_monitor.py
@@ -122,6 +122,7 @@ class ctlog:
def log(self, string):
s = time.strftime('%Y-%m-%d %H:%M:%S') + " " + string
+ s = datetime.datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') + " " + string
with open(self.logfile, 'a') as f:
f.write(s + "\n")
f.close()
@@ -133,12 +134,11 @@ class ctlog:
self.log("Failed to fetch STH. " +str(e))
return
- # try:
- check_sth_signature(self.url, new_sth, base64.b64decode(self.key))
- # check_sth_signature(self.url, new_sth, None)
- # except:
- # self.log("ERROR: Could not verify STH signature")
- # print "ERROR: Could not verify STH signature from " + self.url
+ try:
+ check_sth_signature(self.url, new_sth, base64.b64decode(self.key))
+ except:
+ self.log("ERROR: Could not verify STH signature")
+ print "ERROR: Could not verify STH signature from " + self.url
sth_time = datetime.datetime.fromtimestamp(new_sth['timestamp'] / 1000, UTC()).strftime("%Y-%m-%d %H:%M:%S")
if new_sth["timestamp"] != self.sth["timestamp"]:
@@ -444,17 +444,17 @@ def main(args):
open(CONFIG.DOMAINS_FILE, 'w').write(json.dumps(domain_dict))
# Something went horribly wrong!
- # except Exception, err:
- # print Exception, err
- # for log in logs:
- # log.save()
-
- # # Save info about monitored domains
- # domain_dict = []
- # if len(monitored_domains) > 0:
- # for md in monitored_domains:
- # domain_dict.append(md.to_dict())
- # open(CONFIG.DOMAINS_FILE, 'w').write(json.dumps(domain_dict))
+ except Exception, err:
+ print Exception, err
+ for log in logs:
+ log.save()
+
+ # Save info about monitored domains
+ domain_dict = []
+ if len(monitored_domains) > 0:
+ for md in monitored_domains:
+ domain_dict.append(md.to_dict())
+ open(CONFIG.DOMAINS_FILE, 'w').write(json.dumps(domain_dict))
diff --git a/monitor/monitor_conf.py b/monitor/monitor_conf.py
index 5b935b3..61df927 100644
--- a/monitor/monitor_conf.py
+++ b/monitor/monitor_conf.py
@@ -1,7 +1,7 @@
# All configuration for the CT monitor is done from this file!
# interval (in seconds) between updates
-INTERVAL = 120
+INTERVAL = 60
# Directories for various output files
OUTPUT_DIR = "output/"