check-auto-snapshot-metrik.py.py hinzugefügt

This commit is contained in:
2025-08-06 00:54:05 +02:00
parent 62c80e7744
commit 52b39bc5bb
+45
View File
@@ -0,0 +1,45 @@
#!/usr/bin/env python3
import glob
import re
result = {}
perf_data = []
# Cron-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 = int(keep_match.group(1))
result[label] = keep
except Exception:
continue
# Wenn leer → CRIT
if not result:
print("2 auto_snapshots - No auto-snapshot cron jobs found")
else:
status_line = " ".join([f"{k}={v}" for k, v in sorted(result.items())])
# Performance-Daten mit Beispiel-Warn-/Krit-Grenzen
for label, keep in sorted(result.items()):
if label == "hourly":
perf_data.append(f"{label}={keep};80;60;0;150")
elif label == "daily":
perf_data.append(f"{label}={keep};10;7;0;30")
elif label == "weekly":
perf_data.append(f"{label}={keep};4;2;0;10")
elif label == "monthly":
perf_data.append(f"{label}={keep};2;1;0;5")
elif label == "frequent":
perf_data.append(f"{label}={keep};10;5;0;30")
else:
perf_data.append(f"{label}={keep};;;") # Ohne Schwellen
print(f"0 auto_snapshots - {status_line} | {' '.join(perf_data)}")