Skip to content

Commit

Permalink
NAS-132049 / 24.10.0.1 / add ixnvdimm output to debug (by yocalebo) (…
Browse files Browse the repository at this point in the history
…by bugclerk) (#236)

* add nvdimm_info

(cherry picked from commit 4de661f)
(cherry picked from commit adc8740)

* Nvdimm info is not serializable

(cherry picked from commit b865ed2)
(cherry picked from commit a2c0b87)

---------

Co-authored-by: Caleb <[email protected]>
Co-authored-by: M. Rehan <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent e9610cc commit f9a49c3
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions ixdiagnose/plugins/hardware.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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(
Expand Down

0 comments on commit f9a49c3

Please sign in to comment.