Skip to content

Commit 42d526c

Browse files
committed
nvme collector
1 parent 3963c6f commit 42d526c

File tree

4 files changed

+197
-0
lines changed

4 files changed

+197
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
###############################################################################
2+
#
3+
# MIT License
4+
#
5+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
#
25+
###############################################################################
26+
from .nvme_plugin import NvmePlugin
27+
28+
__all__ = ["NvmePlugin"]
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
###############################################################################
2+
#
3+
# MIT License
4+
#
5+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
#
25+
###############################################################################
26+
27+
from nodescraper.base import InBandDataCollector
28+
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily
29+
from nodescraper.models import TaskResult
30+
31+
from .nvmedata import NvmeDataModel
32+
33+
34+
class NvmeCollector(InBandDataCollector[NvmeDataModel, None]):
35+
"""Collect NVMe details from the system."""
36+
37+
DATA_MODEL = NvmeDataModel
38+
39+
def collect_data(
40+
self,
41+
args=None,
42+
) -> tuple[TaskResult, NvmeDataModel | None]:
43+
"""Collect detailed NVMe information from the system.
44+
45+
Returns:
46+
tuple[TaskResult, NvmeDataModel | None]: Task result and data model with NVMe command outputs.
47+
"""
48+
data = {}
49+
50+
if self.system_info.os_family == OSFamily.WINDOWS:
51+
self._log_event(
52+
category=EventCategory.SW_DRIVER,
53+
description="NVMe collection not supported on Windows",
54+
priority=EventPriority.WARNING,
55+
)
56+
self.result.message = "NVMe data collection skipped on Windows"
57+
self.result.status = ExecutionStatus.SKIPPED
58+
return self.result, None
59+
60+
commands = [
61+
"nvme smart-log /dev/nvme0",
62+
"nvme error-log /dev/nvme0 --log-entries=256",
63+
"nvme id-ctrl /dev/nvme0",
64+
"nvme id-ns /dev/nvme0",
65+
"nvme fw-log /dev/nvme0",
66+
"nvme self-test-log /dev/nvme0",
67+
"nvme telemetry-log /dev/nvme0",
68+
]
69+
70+
for cmd in commands:
71+
res = self._run_sut_cmd(cmd)
72+
if res.exit_code == 0:
73+
data[cmd] = res.stdout
74+
else:
75+
self._log_event(
76+
category=EventCategory.SW_DRIVER,
77+
description="Failed to execute NVMe command",
78+
data={"command": cmd, "exit_code": res.exit_code},
79+
priority=EventPriority.ERROR,
80+
console_log=True,
81+
)
82+
83+
if data:
84+
nvme_data = NvmeDataModel(nvme_data=data)
85+
self._log_event(
86+
category=EventCategory.SW_DRIVER,
87+
description="Collected NVMe data",
88+
data=nvme_data.model_dump(),
89+
priority=EventPriority.INFO,
90+
)
91+
self.result.message = "NVMe data successfully collected"
92+
else:
93+
nvme_data = None
94+
self._log_event(
95+
category=EventCategory.SW_DRIVER,
96+
description="Failed to collect any NVMe data",
97+
priority=EventPriority.CRITICAL,
98+
)
99+
self.result.message = "No NVMe data collected"
100+
self.result.status = ExecutionStatus.ERROR
101+
102+
return self.result, nvme_data
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
###############################################################################
2+
#
3+
# MIT License
4+
#
5+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
#
25+
###############################################################################
26+
from nodescraper.base import InBandDataPlugin
27+
28+
from .nvme_collector import NvmeCollector
29+
from .nvmedata import NvmeDataModel
30+
31+
32+
class NvmePlugin(InBandDataPlugin[NvmeDataModel, None]):
33+
"""Plugin for collection and analysis of nvme data"""
34+
35+
DATA_MODEL = NvmeDataModel
36+
37+
COLLECTOR = NvmeCollector
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
###############################################################################
2+
#
3+
# MIT License
4+
#
5+
# Copyright (c) 2025 Advanced Micro Devices, Inc.
6+
#
7+
# Permission is hereby granted, free of charge, to any person obtaining a copy
8+
# of this software and associated documentation files (the "Software"), to deal
9+
# in the Software without restriction, including without limitation the rights
10+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
# copies of the Software, and to permit persons to whom the Software is
12+
# furnished to do so, subject to the following conditions:
13+
#
14+
# The above copyright notice and this permission notice shall be included in all
15+
# copies or substantial portions of the Software.
16+
#
17+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
# SOFTWARE.
24+
#
25+
###############################################################################
26+
from nodescraper.models import DataModel
27+
28+
29+
class NvmeDataModel(DataModel):
30+
data: dict

0 commit comments

Comments
 (0)