Skip to content

Commit

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

* add nvdimm_info

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

* Nvdimm info is not serializable

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

---------

Co-authored-by: Caleb <[email protected]>
Co-authored-by: M. Rehan <[email protected]>
  • Loading branch information
3 people authored Oct 31, 2024
1 parent 79f9e44 commit 7e365c0
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 7e365c0

Please sign in to comment.