From f9a49c35c4c7d08b598511af3c1ba12419db08b6 Mon Sep 17 00:00:00 2001 From: bugclerk <40872210+bugclerk@users.noreply.github.com> Date: Thu, 31 Oct 2024 05:23:44 -0700 Subject: [PATCH] NAS-132049 / 24.10.0.1 / add ixnvdimm output to debug (by yocalebo) (by bugclerk) (#236) * add nvdimm_info (cherry picked from commit 4de661f60c306c1047692342094224143423283c) (cherry picked from commit adc87409aeca8a5ba972ef3fa5de7814a9953797) * Nvdimm info is not serializable (cherry picked from commit b865ed299ba95cf624132511dffb6aea0f63aed9) (cherry picked from commit a2c0b87c965881c57fa67a8c4038b8a30f42fe10) --------- Co-authored-by: Caleb Co-authored-by: M. Rehan --- ixdiagnose/plugins/hardware.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/ixdiagnose/plugins/hardware.py b/ixdiagnose/plugins/hardware.py index db8f5cd..cfb3825 100644 --- a/ixdiagnose/plugins/hardware.py +++ b/ixdiagnose/plugins/hardware.py @@ -1,8 +1,27 @@ +import os +import re +import typing + from ixdiagnose.utils.command import Command -from ixdiagnose.utils.middleware import MiddlewareCommand +from ixdiagnose.utils.middleware import MiddlewareClient, MiddlewareCommand +from ixdiagnose.utils.run import run from .base import Plugin -from .metrics import CommandMetric, FileMetric, MiddlewareClientMetric +from .metrics import CommandMetric, FileMetric, MiddlewareClientMetric, PythonMetric + + +def nvdimm_info(client: MiddlewareClient, context: typing.Any) -> str: + nmem = re.compile(r'^nmem\d+$') + output = '' + with os.scandir('/dev/') as sdir: + for i in filter(lambda x: nmem.match(x.name), sdir): + output += f"{'=' * 20} {i.path} {'=' * 20}" + cp = run(f'/usr/local/sbin/ixnvdimm {i.path}', check=False) + if cp.returncode: + output += f'Failed to retrieve nvdimm info: {cp.stderr}\n\n' + else: + output += f'{cp.stdout}\n\n' + return output class Hardware(Plugin): @@ -28,6 +47,7 @@ class Hardware(Plugin): MiddlewareClientMetric('disks_config', [MiddlewareCommand('disk.query')]), MiddlewareClientMetric('enclosure2', [MiddlewareCommand('enclosure2.query')]), MiddlewareClientMetric('enclosures', [MiddlewareCommand('enclosure.query')]), + PythonMetric('nvdimm_info', nvdimm_info, serializable=False), ] raw_metrics = [ CommandMetric(