X-Git-Url: https://wannabe.guru.org/gitweb/?a=blobdiff_plain;ds=inline;f=health_renderer.py;h=cfa6a8a2dfd0f47ff6777a7e09fab95c53b97721;hb=da3a11e9fcea80a7700eb54605512d331a9ec612;hp=5416af2fb1bebb847af55f8522b9edfb27232624;hpb=6b8d4eeb7153617221f822a243a117f0bcab07bf;p=kiosk.git diff --git a/health_renderer.py b/health_renderer.py index 5416af2..cfa6a8a 100644 --- a/health_renderer.py +++ b/health_renderer.py @@ -1,14 +1,11 @@ #!/usr/bin/env python3 import logging -import os -import time +import subprocess from typing import Dict -import constants import file_writer import renderer -import utils logger = logging.getLogger(__file__) @@ -20,141 +17,12 @@ class periodic_health_renderer(renderer.abstaining_renderer): def periodic_render(self, key: str) -> bool: with file_writer.file_writer("periodic-health_6_300.html") as f: - timestamps = "/timestamps/" - days = constants.seconds_per_day - hours = constants.seconds_per_hour - mins = constants.seconds_per_minute - minutes = mins - limits = { - timestamps + "last_http_probe_wannabe_house": mins * 10, - timestamps + "last_http_probe_meerkat_cabin": mins * 10, - timestamps + "last_http_probe_dns_house": mins * 10, - timestamps + "last_http_probe_rpi_cabin": mins * 10, - timestamps + "last_http_probe_rpi_house": mins * 10, - timestamps + "last_http_probe_therm_house": mins * 10, - timestamps + "last_rsnapshot_hourly": hours * 24, - timestamps + "last_rsnapshot_daily": days * 3, - timestamps + "last_rsnapshot_weekly": days * 14, - timestamps + "last_rsnapshot_monthly": days * 70, - 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, - timestamps + "last_zfs_scrub": days * 9, - timestamps + "last_backup_zfs_scrub": days * 9, - timestamps + "last_cabin_zfs_scrub": days * 9, - 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_short": days * 14, - timestamps + "last_disk_selftest_long": days * 31, - timestamps + "last_backup_disk_selftest_short": days * 14, - timestamps + "last_backup_disk_selftest_long": days * 31, - timestamps + "last_cabin_disk_selftest_short": days * 14, - timestamps + "last_cabin_disk_selftest_long": days * 31, - timestamps + "last_cabin_rpi_ping": mins * 20, - timestamps + "last_healthy_wifi": mins * 10, - timestamps + "last_healthy_network": mins * 10, - timestamps + "last_scott_sync": days * 2, - } - self.write_header(f) - - now = time.time() - n = 0 - for filepath, limit_sec in sorted(limits.items()): - ts = os.stat(filepath).st_mtime - age = now - ts - logger.debug(f"{filepath} -- age: {age}, limit {limit_sec}") - if age < limits[filepath]: - # OK - f.write( - '