commit 62c80e7744a00170597841b10a559dc333e7a5bf Author: patrick Date: Wed Aug 6 00:53:14 2025 +0200 check-auto-snapshot.py hinzugefügt diff --git a/check-auto-snapshot.py b/check-auto-snapshot.py new file mode 100644 index 0000000..3240708 --- /dev/null +++ b/check-auto-snapshot.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 +import glob +import re + +result = {} + +# Alle passenden Dateien finden +cron_paths = glob.glob("/etc/cron*/*-auto-snapshot") + +for path in cron_paths: + try: + with open(path, 'r') as f: + content = f.read() + label_match = re.search(r'--label=([a-zA-Z]+)', content) + keep_match = re.search(r'--keep=(\d+)', content) + if label_match and keep_match: + label = label_match.group(1) + keep = keep_match.group(1) + result[label] = keep + except Exception: + continue # Datei konnte nicht gelesen werden + +# Ausgabe im Checkmk Local Check Format +if not result: + print("2 auto_snapshots - No auto-snapshot cron jobs found") +else: + formatted = " ".join([f"{k}={v}" for k, v in sorted(result.items())]) + print(f"0 auto_snapshots - {formatted}")