Add initial Restic backup telemetry collector
This commit is contained in:
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user