check-auto-snapshot.py hinzugefügt
This commit is contained in:
@@ -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}")
|
||||||
Reference in New Issue
Block a user