We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef8c077 commit edd3766Copy full SHA for edd3766
btrfs_stats.py
@@ -12,6 +12,8 @@
12
from prometheus_client import CollectorRegistry, Gauge, generate_latest
13
14
15
+DEVICE_PATTERN = re.compile(r"^\[([^\]]+)\]\.(\S+)\s+(\d+)$", re.MULTILINE)
16
+
17
def get_btrfs_mount_points():
18
"""List all btrfs mount points.
19
@@ -47,7 +49,7 @@ def get_btrfs_errors(mountpoint):
47
49
continue
48
50
# Sample line:
51
# [/dev/vdb1].flush_io_errs 0
- m = re.search(r"^\[([^\]]+)\]\.(\S+)\s+(\d+)$", line.decode("utf-8"))
52
+ m = DEVICE_PATTERN.match(line.decode("utf-8"))
53
if not m:
54
raise RuntimeError("unexpected output from btrfs: '%s'" % line)
55
yield m.group(1), m.group(2), int(m.group(3))
0 commit comments