From 26c8edc5b2b3605ddd465b9fa1072bd6fa7f5aea Mon Sep 17 00:00:00 2001 From: caleb Date: Mon, 28 Oct 2024 12:49:44 -0400 Subject: [PATCH 1/2] add zvols to zvol_config.txt --- ixdiagnose/plugins/zfs.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/ixdiagnose/plugins/zfs.py b/ixdiagnose/plugins/zfs.py index cb7c1e2..b1898c5 100644 --- a/ixdiagnose/plugins/zfs.py +++ b/ixdiagnose/plugins/zfs.py @@ -30,8 +30,8 @@ def zfs_getacl_impl(dataset_name: str, props_dict: dict) -> str: def resource_output(client: MiddlewareClient, resource_type: str) -> str: - if resource_type == 'zfs': - cp = run(['zfs', 'get', 'all', '-t', 'filesystem'], check=False) + if resource_type in ('filesystem', 'volume'): + cp = run(['zfs', 'get', 'all', '-t', resource_type], check=False) else: cp = run([resource_type, 'get', 'all'], check=False) if cp.returncode: @@ -46,7 +46,7 @@ def resource_output(client: MiddlewareClient, resource_type: str) -> str: for index, resource_line in enumerate(filter(bool, map(str.strip, output_lines[1:]))): resource_name = resource_line.split()[0].strip() if resource_context != resource_name: - if resource_context is not None and resource_type == 'zfs': + if resource_context is not None and resource_type == 'filesystem': output += zfs_getacl(resource_context, prop_dict) prop_dict = {} @@ -56,14 +56,14 @@ def resource_output(client: MiddlewareClient, resource_type: str) -> str: output += f'{props_header}\n' resource_context = resource_name - if resource_type == 'zfs': + if resource_type == 'filesystem': prop = resource_line.split()[1] if prop in prop_list: prop_dict[prop] = resource_line.split()[2] output += f'{resource_line}\n' - if resource_name is not None and resource_type == 'zfs': + if resource_name is not None and resource_type == 'filesystem': output += zfs_getacl(resource_name, prop_dict) return output @@ -128,7 +128,8 @@ class ZFS(Plugin): ), ] ), - PythonMetric('dataset_config', resource_output, 'zfs', 'ZFS Datasets Configuration', serializable=False), + PythonMetric('dataset_config', resource_output, 'filesystem', 'ZFS Datasets Configuration', serializable=False), + PythonMetric('zvol_config', resource_output, 'volume', 'ZFS ZVOL Configuration', serializable=False), PythonMetric('pool_config', resource_output, 'zpool', 'ZFS Pools Configuration', serializable=False), ] serializable_metrics = [ From 2ab4bd6a809939c976be4e579d08e4de15e7682c Mon Sep 17 00:00:00 2001 From: caleb Date: Mon, 28 Oct 2024 13:52:52 -0400 Subject: [PATCH 2/2] fix unit tests --- ixdiagnose/plugins/zfs.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ixdiagnose/plugins/zfs.py b/ixdiagnose/plugins/zfs.py index b1898c5..bfb1cf8 100644 --- a/ixdiagnose/plugins/zfs.py +++ b/ixdiagnose/plugins/zfs.py @@ -37,6 +37,7 @@ def resource_output(client: MiddlewareClient, resource_type: str) -> str: if cp.returncode: return f'Failed to retrieve {resource_type!r} resources: {cp.stderr}' + base = 'zpool get all' if resource_type == 'zpool' else 'zfs get all' prop_list = {'acltype', 'mounted', 'mountpoint'} resource_context = resource_name = None output = '' @@ -50,7 +51,7 @@ def resource_output(client: MiddlewareClient, resource_type: str) -> str: output += zfs_getacl(resource_context, prop_dict) prop_dict = {} - header_str = f'{resource_type} get all {resource_name}' + header_str = f'{base} {resource_name}' next_line = '\n\n' if index != 0 else '' output += f'{next_line}{"=" * (len(header_str) + 5)}\n {header_str}\n{"=" * (len(header_str) + 5)}\n\n' output += f'{props_header}\n'