diff options
Diffstat (limited to 'monitor/josef_monitor.py')
-rwxr-xr-x | monitor/josef_monitor.py | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/monitor/josef_monitor.py b/monitor/josef_monitor.py index d97ba02..8b29443 100755 --- a/monitor/josef_monitor.py +++ b/monitor/josef_monitor.py @@ -46,6 +46,7 @@ class ctlog: self.logfile = CONFIG.OUTPUT_DIR + name + ".log" self.savefile = CONFIG.OUTPUT_DIR + name + "-state-info.json" self.subtree = [[]] + self.fe_ips = {} self.sth = None self.entries = 0 self.root_hash = None @@ -141,6 +142,7 @@ class ctlog: d["entries"] = self.entries d["subtree"] = encode_tree(self.subtree) d["sth"] = self.sth + d["fe_ips"] = self.fe_ips return d def save(self): @@ -156,11 +158,18 @@ class ctlog: self.subtree = decode_tree(d["subtree"]) self.sth = d["sth"] self.entries = d["entries"] + + if "fe_ips" in d: + self.fe_ips = d["fe_ips"] + else: + self.fe_ips = {} + except IOError, e: if e.errno == errno.ENOENT: return None raise e + 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 @@ -170,9 +179,12 @@ class ctlog: def update_sth(self): try: - new_sth = get_sth(self.url) + new_sth, ip = get_sth_and_ip(self.url) + if not ip in self.fe_ips: + self.fe_ips[ip] = new_sth["timestamp"] + self.log("New Front end IP: " + ip) except Exception, e: - self.log(ERROR_STR + "Failed to fetch STH. " +str(e)) + self.log(ERROR_STR + "Failed to fetch STH and IP. " +str(e)) return try: |