2.3 KiB
health
Purpose
Self-monitoring and housekeeping. Periodically checks disk usage and MQTT reachability, publishes an aggregated system-health snapshot, auto-prunes old recordings when the disk gets full, builds a daily "what happened today" digest, and drives the scheduled firing of highlight-reel and timelapse jobs.
Key files
vigilar/health/monitor.py—HealthMonitorsubsystem loop: disk check every 5 min, MQTT port check every 30 s, status publish every 10 s, daily reel trigger, per-minute timelapse schedule checkvigilar/health/pruner.py—auto_prune/find_prunable_recordings; deletes oldest unstarred recordings (and their thumbnails) until usage is back under targetvigilar/health/digest.py—build_digest: counts person/vehicle events, pet and wildlife sightings, and recording totals over a time window for notification digestsvigilar/health/__init__.py
MQTT topics
Subscribes: none Publishes:
vigilar/system/health— rolled-up health status with per-check breakdown
Database tables
recordings— read in pruner (starred = 0, oldest first) and deleted row-by-row once the file is unlinkedevents,pet_sightings,wildlife_sightings,recordings— read indigest.pytimelapse_schedules— read indirectly viavigilar.highlights.timelapse.check_schedules
Depends on
storage— all DB accesshighlights— callsgenerate_daily_reelandcheck_scheduleson schedule- Filesystem —
shutil.disk_usageonsystem.data_dir
Consumed by
web— surfacesvigilar/system/healthand the digest output in the system blueprintevents— ingestsvigilar/system/healthoff the bus (subscribes to everything)
Notes
The pruner is keyed on percentages, not gigabytes: it checks config.health.disk_warn_pct / disk_critical_pct for alerting and prunes toward config.health.auto_prune_target_pct. It never deletes a recording whose starred flag is set, and it unlinks the thumbnail alongside the video. The monitor owns the scheduling clock for both generate_daily_reel (fires when wall-clock matches highlights.generate_time) and timelapse generation (polls check_schedules every 60 s), so neither highlights/ nor its cron is wired directly into the supervisor.