diff --git a/check-snapshot-age b/check-snapshot-age index 2b679f9..aeadfde 100644 --- a/check-snapshot-age +++ b/check-snapshot-age @@ -5,13 +5,16 @@ import re import time import argparse +# ZFS-Pfad ermitteln +zfs = subprocess.check_output(["which", "zfs"]).decode().strip() + # Argumente verarbeiten parser = argparse.ArgumentParser(description="ZFS Snapshot Übersicht") parser.add_argument("--filter", help="Nur bestimmte Datasets anzeigen (Regex möglich, z.B. 'rpool/ROOT')", type=str) args = parser.parse_args() # Snapshots abrufen -_snapshots = subprocess.check_output("/usr/sbin/zfs list -t snapshot -Hpo name,creation".split()) +_snapshots = subprocess.check_output([zfs, "list", "-t", "snapshot", "-Hpo", "name,creation"]) LABELS = ("frequent", "hourly", "daily", "weekly", "monthly", "yearly", "backup-zfs", "bashclub-zfs") RE_LABELSEARCH = re.compile("|".join(LABELS)) @@ -32,10 +35,10 @@ for _datastore, _snapshot, _creation in re.findall(r"^([\w_./-]+)@([\w_.-]+)\t(\ _datasets[_datastore][_label].append((_snapshot, int(_creation))) # Ergebnisse anzeigen -for _datastore in _datasets.keys(): +for _datastore in _datasets: print(_datastore) print("-" * 40) - for _label in _datasets[_datastore].keys(): + for _label in _datasets[_datastore]: _data = _datasets[_datastore][_label] _first = time.strftime("%d.%m.%Y %H:%M:%S", time.localtime(_data[0][1])) _last = time.strftime("%d.%m.%Y %H:%M:%S", time.localtime(_data[-1][1]))