#!{{ python_executable }} import cgi import datetime import os import sqlite3 db_path = '{{ monitor_db_path }}' status_history_length = '{{ status_history_length }}' db = sqlite3.connect(db_path) print """

Monitor Status History :

""" def get_date_from_timestamp(timestamp): return datetime.datetime.fromtimestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S') def print_individual_status(timestamp): print "

Failure on %s

" if not os.path.exists(db_path): print """No status history found

""" exit(0) failure_row_list = db.execute("select timestamp from status where status='FAILURE' order by timestamp desc limit ?", status_history_length ) for failure_row in failure_row_list: timestamp, = failure_row print_individual_status(timestamp) print ""