8 class periodic_health_renderer(renderer.debuggable_abstaining_renderer):
9 def __init__(self, name_to_timeout_dict):
10 super(periodic_health_renderer, self).__init__(name_to_timeout_dict, False)
12 def debug_prefix(self):
15 def periodic_render(self, key):
16 f = file_writer.file_writer("periodic-health_6_300.html")
17 timestamps = "/timestamps/"
18 days = constants.seconds_per_day
19 hours = constants.seconds_per_hour
20 mins = constants.seconds_per_minute
23 timestamps + "last_http_probe_wannabe_house": mins * 10,
24 timestamps + "last_http_probe_meerkat_cabin": mins * 10,
25 timestamps + "last_http_probe_dns_house": mins * 10,
26 timestamps + "last_http_probe_rpi_cabin": mins * 10,
27 timestamps + "last_http_probe_rpi_house": mins * 10,
28 timestamps + "last_http_probe_therm_house": mins * 10,
29 timestamps + "last_rsnapshot_hourly": hours * 24,
30 timestamps + "last_rsnapshot_daily": days * 3,
31 timestamps + "last_rsnapshot_weekly": days * 14,
32 timestamps + "last_rsnapshot_monthly": days * 70,
33 timestamps + "last_zfssnapshot_hourly": hours * 5,
34 timestamps + "last_zfssnapshot_daily": hours * 36,
35 timestamps + "last_zfssnapshot_weekly": days * 9,
36 timestamps + "last_zfssnapshot_monthly": days * 70,
37 timestamps + "last_zfssnapshot_cleanup": hours * 24,
38 timestamps + "last_zfs_scrub": days * 9,
39 timestamps + "last_backup_zfs_scrub": days * 9,
40 timestamps + "last_cabin_zfs_scrub": days * 9,
41 timestamps + "last_zfsxfer_backup.house": hours * 36,
42 timestamps + "last_zfsxfer_ski.dyn.guru.org": days * 7,
43 timestamps + "last_photos_sync": hours * 8,
44 timestamps + "last_disk_selftest_short": days * 14,
45 timestamps + "last_disk_selftest_long": days * 31,
46 timestamps + "last_backup_disk_selftest_short": days * 14,
47 timestamps + "last_backup_disk_selftest_long": days * 31,
48 timestamps + "last_cabin_disk_selftest_short": days * 14,
49 timestamps + "last_cabin_disk_selftest_long": days * 31,
50 timestamps + "last_cabin_rpi_ping": mins * 10,
51 timestamps + "last_healthy_wifi": mins * 10,
52 timestamps + "last_healthy_network": mins * 10,
53 timestamps + "last_scott_sync": days * 2,
59 for x in sorted(limits):
60 ts = os.stat(x).st_mtime
62 self.debug_print("%s -- age is %ds, limit is %ds" % (x, age, limits[x]))
65 '<TD BGCOLOR="#007010" HEIGHT=100 WIDTH=33% STYLE="text-size:60%; vertical-align: middle;">\n'
69 '<TD BGCOLOR="#990000" HEIGHT=100 WIDTH=33% CLASS="invalid" STYLE="text-size:60%; vertical-align:middle;">\n'
71 f.write(" <CENTER><FONT SIZE=-2>\n")
73 name = x.replace(timestamps, "")
74 name = name.replace("last_", "")
75 name = name.replace("_", " ")
76 days = divmod(age, constants.seconds_per_day)
77 hours = divmod(days[1], constants.seconds_per_hour)
78 minutes = divmod(hours[1], constants.seconds_per_minute)
81 "%s is %d days %02d:%02d old." % (name, days[0], hours[0], minutes[0])
84 "%s<BR>\n<B>%d</b> days <B>%02d</B>:<B>%02d</B> old.\n"
85 % (name, days[0], hours[0], minutes[0])
87 f.write("</FONT></CENTER>\n</TD>\n\n")
90 f.write("</TR>\n<TR>\n<!-- ------------------- -->\n")
95 def write_header(self, f):
101 @-webkit-keyframes invalid {
102 from { background-color: #ff6400; }
103 to { background-color: #ff0000; }
107 @-moz-keyframes invalid {
108 from { background-color: #ff6400; }
109 to { background-color: #ff0000; }
113 @-o-keyframes invalid {
114 from { background-color: #ff6400; }
115 to { background-color: #ff0000; }
120 from { background-color: #ff6400; }
121 to { background-color: #ff0000; }
126 -webkit-animation: invalid 1s infinite; /* Safari 4+ */
127 -moz-animation: invalid 1s infinite; /* Fx 5+ */
128 -o-animation: invalid 1s infinite; /* Opera 12+ */
129 animation: invalid 1s infinite; /* IE 10+ */
132 <meta http-equiv="cache-control" content="max-age=0" />
133 <meta http-equiv="cache-control" content="no-cache" />
134 <meta http-equiv="expires" content="0" />
135 <meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
136 <meta http-equiv="pragma" content="no-cache" />
139 <H1>Periodic Cronjob Health Report</H1>
142 <TABLE BORDER=0 WIDTH=99% style="font-size:16pt">
147 def write_footer(self, f):
157 test = periodic_health_renderer({"Test", 123})
158 test.periodic_render("Test")