X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=inline;f=health_renderer.py;h=cfa6a8a2dfd0f47ff6777a7e09fab95c53b97721;hb=2b7583ad79a2adb41b08a1086a9a780da83b776c;hp=4eeba985163d8d512ef8f60ce3151e09ddc6262c;hpb=e932e65d4847a4777ddae297f9e52349285221ed;p=kiosk.git diff --git a/health_renderer.py b/health_renderer.py index 4eeba98..cfa6a8a 100644 --- a/health_renderer.py +++ b/health_renderer.py @@ -1,138 +1,28 @@ -import constants -import file_writer -import os -import renderer -import time - -class periodic_health_renderer(renderer.debuggable_abstaining_renderer): - def __init__(self, name_to_timeout_dict): - super(periodic_health_renderer, self).__init__(name_to_timeout_dict, False) - - def debug_prefix(self): - return "health" - - def periodic_render(self, key): - f = file_writer.file_writer('periodic-health_6_300.html') - timestamps = '/timestamps/' - days = constants.seconds_per_day - hours = constants.seconds_per_hour - mins = constants.seconds_per_minute - limits = { - timestamps + 'last_rsnapshot_hourly' : hours * 24, - timestamps + 'last_rsnapshot_daily' : days * 3, - timestamps + 'last_rsnapshot_weekly' : days * 14, - timestamps + 'last_rsnapshot_monthly' : days * 70, +#!/usr/bin/env python3 - timestamps + 'last_zfssnapshot_hourly' : hours * 5, - timestamps + 'last_zfssnapshot_daily' : hours * 36, - timestamps + 'last_zfssnapshot_weekly' : days * 9, - timestamps + 'last_zfssnapshot_monthly' : days * 70, - timestamps + 'last_zfssnapshot_cleanup' : hours * 24, +import logging +import subprocess +from typing import Dict - timestamps + 'last_disk_selftest_short' : days * 14, - timestamps + 'last_disk_selftest_long' : days * 31, - timestamps + 'last_zfs_scrub' : days * 9, - timestamps + 'last_zfs_scrub_backup' : days * 9, +import file_writer +import renderer - timestamps + 'last_zfsxfer_backup.house' : hours * 36, - timestamps + 'last_zfsxfer_ski.dyn.guru.org' : days * 7, - timestamps + 'last_photos_sync' : hours * 8, - timestamps + 'last_disk_selftest_backup_short': days * 14, - timestamps + 'last_disk_selftest_backup_long' : days * 31, - timestamps + 'last_healthy_wifi' : mins * 10, - timestamps + 'last_healthy_network' : mins * 10, - timestamps + 'last_scott_sync' : days * 2, - } - self.write_header(f) +logger = logging.getLogger(__file__) - now = time.time() - n = 0 - for x in sorted(limits): - ts = os.stat(x).st_mtime - age = now - ts - self.debug_print("%s -- age is %ds, limit is %ds" % (x, age, limits[x])) - if age < limits[x]: - f.write('