check-snapshot-age aktualisiert
This commit is contained in:
+2
-5
@@ -5,23 +5,20 @@ import re
|
|||||||
import time
|
import time
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
# ZFS-Pfad ermitteln
|
|
||||||
zfs = subprocess.check_output(["which", "zfs"]).decode().strip()
|
|
||||||
|
|
||||||
# Argumente verarbeiten
|
# Argumente verarbeiten
|
||||||
parser = argparse.ArgumentParser(description="ZFS Snapshot Übersicht")
|
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)
|
parser.add_argument("--filter", help="Nur bestimmte Datasets anzeigen (Regex möglich, z.B. 'rpool/ROOT')", type=str)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# Snapshots abrufen
|
# Snapshots abrufen
|
||||||
_snapshots = subprocess.check_output([zfs, "list", "-t", "snapshot", "-Hpo", "name,creation"])
|
_snapshots = subprocess.check_output(["zfs", "list", "-t", "snapshot", "-Hpo", "name,creation"],encoding="utf-8")
|
||||||
|
|
||||||
_datasets = {}
|
_datasets = {}
|
||||||
|
|
||||||
# Snapshots parsen
|
# Snapshots parsen
|
||||||
for _datastore, _snapshot, _creation in re.findall(
|
for _datastore, _snapshot, _creation in re.findall(
|
||||||
r"^([\w_./-]+)@([\w_.:-]+)\t(\d+)",
|
r"^([\w_./-]+)@([\w_.:-]+)\t(\d+)",
|
||||||
_snapshots.decode('utf-8'),
|
_snapshots,
|
||||||
re.M):
|
re.M):
|
||||||
|
|
||||||
if args.filter and not re.search(args.filter, _datastore):
|
if args.filter and not re.search(args.filter, _datastore):
|
||||||
|
|||||||
Reference in New Issue
Block a user