Add initial Restic backup telemetry collector

This commit is contained in:
2026-07-27 23:08:30 -04:00
parent 080f10a1e0
commit 0ff68ce4bf
5 changed files with 54 additions and 0 deletions
View File
Binary file not shown.
Binary file not shown.
+32
View File
@@ -0,0 +1,32 @@
#!/usr/bin/env python3
import subprocess
import json
RESTIC_ENV = "/etc/restic/edge01.env"
def collect():
cmd = f'. "{RESTIC_ENV}" && restic snapshots --json'
result = subprocess.run(
["bash", "-c", cmd],
capture_output=True,
text=True,
)
if result.returncode != 0:
return {
"state": "offline",
"summary": "Restic error",
"detail": result.stderr.strip()
}
snapshots = json.loads(result.stdout)
return {
"state": "online",
"summary": "Healthy",
"detail": f"{len(snapshots)} snapshots",
"snapshot_count": len(snapshots)
}