amd-node-scraper 0.0.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- amd_node_scraper-0.0.1.dist-info/LICENSE +21 -0
- amd_node_scraper-0.0.1.dist-info/METADATA +424 -0
- amd_node_scraper-0.0.1.dist-info/RECORD +197 -0
- amd_node_scraper-0.0.1.dist-info/WHEEL +5 -0
- amd_node_scraper-0.0.1.dist-info/entry_points.txt +2 -0
- amd_node_scraper-0.0.1.dist-info/top_level.txt +1 -0
- nodescraper/__init__.py +32 -0
- nodescraper/base/__init__.py +34 -0
- nodescraper/base/inbandcollectortask.py +118 -0
- nodescraper/base/inbanddataplugin.py +39 -0
- nodescraper/base/regexanalyzer.py +120 -0
- nodescraper/cli/__init__.py +29 -0
- nodescraper/cli/cli.py +511 -0
- nodescraper/cli/constants.py +27 -0
- nodescraper/cli/dynamicparserbuilder.py +171 -0
- nodescraper/cli/helper.py +517 -0
- nodescraper/cli/inputargtypes.py +129 -0
- nodescraper/configbuilder.py +123 -0
- nodescraper/configregistry.py +66 -0
- nodescraper/configs/node_status.json +19 -0
- nodescraper/connection/__init__.py +25 -0
- nodescraper/connection/inband/__init__.py +46 -0
- nodescraper/connection/inband/inband.py +171 -0
- nodescraper/connection/inband/inbandlocal.py +93 -0
- nodescraper/connection/inband/inbandmanager.py +151 -0
- nodescraper/connection/inband/inbandremote.py +173 -0
- nodescraper/connection/inband/sshparams.py +43 -0
- nodescraper/constants.py +26 -0
- nodescraper/enums/__init__.py +40 -0
- nodescraper/enums/eventcategory.py +89 -0
- nodescraper/enums/eventpriority.py +42 -0
- nodescraper/enums/executionstatus.py +44 -0
- nodescraper/enums/osfamily.py +34 -0
- nodescraper/enums/systeminteraction.py +41 -0
- nodescraper/enums/systemlocation.py +33 -0
- nodescraper/generictypes.py +36 -0
- nodescraper/interfaces/__init__.py +44 -0
- nodescraper/interfaces/connectionmanager.py +143 -0
- nodescraper/interfaces/dataanalyzertask.py +138 -0
- nodescraper/interfaces/datacollectortask.py +185 -0
- nodescraper/interfaces/dataplugin.py +356 -0
- nodescraper/interfaces/plugin.py +127 -0
- nodescraper/interfaces/resultcollator.py +56 -0
- nodescraper/interfaces/task.py +164 -0
- nodescraper/interfaces/taskresulthook.py +39 -0
- nodescraper/models/__init__.py +48 -0
- nodescraper/models/analyzerargs.py +93 -0
- nodescraper/models/collectorargs.py +30 -0
- nodescraper/models/connectionconfig.py +34 -0
- nodescraper/models/datamodel.py +171 -0
- nodescraper/models/datapluginresult.py +39 -0
- nodescraper/models/event.py +158 -0
- nodescraper/models/pluginconfig.py +38 -0
- nodescraper/models/pluginresult.py +39 -0
- nodescraper/models/systeminfo.py +44 -0
- nodescraper/models/taskresult.py +185 -0
- nodescraper/models/timerangeargs.py +38 -0
- nodescraper/pluginexecutor.py +274 -0
- nodescraper/pluginregistry.py +152 -0
- nodescraper/plugins/__init__.py +25 -0
- nodescraper/plugins/inband/__init__.py +25 -0
- nodescraper/plugins/inband/amdsmi/__init__.py +28 -0
- nodescraper/plugins/inband/amdsmi/amdsmi_analyzer.py +821 -0
- nodescraper/plugins/inband/amdsmi/amdsmi_collector.py +1313 -0
- nodescraper/plugins/inband/amdsmi/amdsmi_plugin.py +43 -0
- nodescraper/plugins/inband/amdsmi/amdsmidata.py +1002 -0
- nodescraper/plugins/inband/amdsmi/analyzer_args.py +50 -0
- nodescraper/plugins/inband/amdsmi/cper.py +65 -0
- nodescraper/plugins/inband/bios/__init__.py +29 -0
- nodescraper/plugins/inband/bios/analyzer_args.py +64 -0
- nodescraper/plugins/inband/bios/bios_analyzer.py +93 -0
- nodescraper/plugins/inband/bios/bios_collector.py +93 -0
- nodescraper/plugins/inband/bios/bios_plugin.py +43 -0
- nodescraper/plugins/inband/bios/biosdata.py +30 -0
- nodescraper/plugins/inband/cmdline/__init__.py +25 -0
- nodescraper/plugins/inband/cmdline/analyzer_args.py +80 -0
- nodescraper/plugins/inband/cmdline/cmdline_analyzer.py +113 -0
- nodescraper/plugins/inband/cmdline/cmdline_collector.py +77 -0
- nodescraper/plugins/inband/cmdline/cmdline_plugin.py +43 -0
- nodescraper/plugins/inband/cmdline/cmdlinedata.py +30 -0
- nodescraper/plugins/inband/device_enumeration/__init__.py +29 -0
- nodescraper/plugins/inband/device_enumeration/analyzer_args.py +73 -0
- nodescraper/plugins/inband/device_enumeration/device_enumeration_analyzer.py +81 -0
- nodescraper/plugins/inband/device_enumeration/device_enumeration_collector.py +176 -0
- nodescraper/plugins/inband/device_enumeration/device_enumeration_plugin.py +45 -0
- nodescraper/plugins/inband/device_enumeration/deviceenumdata.py +36 -0
- nodescraper/plugins/inband/dimm/__init__.py +25 -0
- nodescraper/plugins/inband/dimm/collector_args.py +31 -0
- nodescraper/plugins/inband/dimm/dimm_collector.py +151 -0
- nodescraper/plugins/inband/dimm/dimm_plugin.py +40 -0
- nodescraper/plugins/inband/dimm/dimmdata.py +30 -0
- nodescraper/plugins/inband/dkms/__init__.py +25 -0
- nodescraper/plugins/inband/dkms/analyzer_args.py +85 -0
- nodescraper/plugins/inband/dkms/dkms_analyzer.py +106 -0
- nodescraper/plugins/inband/dkms/dkms_collector.py +76 -0
- nodescraper/plugins/inband/dkms/dkms_plugin.py +43 -0
- nodescraper/plugins/inband/dkms/dkmsdata.py +33 -0
- nodescraper/plugins/inband/dmesg/__init__.py +28 -0
- nodescraper/plugins/inband/dmesg/analyzer_args.py +33 -0
- nodescraper/plugins/inband/dmesg/collector_args.py +39 -0
- nodescraper/plugins/inband/dmesg/dmesg_analyzer.py +503 -0
- nodescraper/plugins/inband/dmesg/dmesg_collector.py +164 -0
- nodescraper/plugins/inband/dmesg/dmesg_plugin.py +44 -0
- nodescraper/plugins/inband/dmesg/dmesgdata.py +116 -0
- nodescraper/plugins/inband/fabrics/__init__.py +28 -0
- nodescraper/plugins/inband/fabrics/fabrics_collector.py +726 -0
- nodescraper/plugins/inband/fabrics/fabrics_plugin.py +37 -0
- nodescraper/plugins/inband/fabrics/fabricsdata.py +140 -0
- nodescraper/plugins/inband/journal/__init__.py +28 -0
- nodescraper/plugins/inband/journal/collector_args.py +33 -0
- nodescraper/plugins/inband/journal/journal_collector.py +107 -0
- nodescraper/plugins/inband/journal/journal_plugin.py +40 -0
- nodescraper/plugins/inband/journal/journaldata.py +44 -0
- nodescraper/plugins/inband/kernel/__init__.py +25 -0
- nodescraper/plugins/inband/kernel/analyzer_args.py +64 -0
- nodescraper/plugins/inband/kernel/kernel_analyzer.py +91 -0
- nodescraper/plugins/inband/kernel/kernel_collector.py +129 -0
- nodescraper/plugins/inband/kernel/kernel_plugin.py +43 -0
- nodescraper/plugins/inband/kernel/kerneldata.py +32 -0
- nodescraper/plugins/inband/kernel_module/__init__.py +25 -0
- nodescraper/plugins/inband/kernel_module/analyzer_args.py +59 -0
- nodescraper/plugins/inband/kernel_module/kernel_module_analyzer.py +211 -0
- nodescraper/plugins/inband/kernel_module/kernel_module_collector.py +264 -0
- nodescraper/plugins/inband/kernel_module/kernel_module_data.py +60 -0
- nodescraper/plugins/inband/kernel_module/kernel_module_plugin.py +43 -0
- nodescraper/plugins/inband/memory/__init__.py +25 -0
- nodescraper/plugins/inband/memory/analyzer_args.py +45 -0
- nodescraper/plugins/inband/memory/memory_analyzer.py +98 -0
- nodescraper/plugins/inband/memory/memory_collector.py +330 -0
- nodescraper/plugins/inband/memory/memory_plugin.py +43 -0
- nodescraper/plugins/inband/memory/memorydata.py +90 -0
- nodescraper/plugins/inband/network/__init__.py +28 -0
- nodescraper/plugins/inband/network/network_collector.py +1828 -0
- nodescraper/plugins/inband/network/network_plugin.py +37 -0
- nodescraper/plugins/inband/network/networkdata.py +319 -0
- nodescraper/plugins/inband/nvme/__init__.py +28 -0
- nodescraper/plugins/inband/nvme/nvme_collector.py +167 -0
- nodescraper/plugins/inband/nvme/nvme_plugin.py +37 -0
- nodescraper/plugins/inband/nvme/nvmedata.py +45 -0
- nodescraper/plugins/inband/os/__init__.py +25 -0
- nodescraper/plugins/inband/os/analyzer_args.py +64 -0
- nodescraper/plugins/inband/os/os_analyzer.py +73 -0
- nodescraper/plugins/inband/os/os_collector.py +131 -0
- nodescraper/plugins/inband/os/os_plugin.py +43 -0
- nodescraper/plugins/inband/os/osdata.py +31 -0
- nodescraper/plugins/inband/package/__init__.py +25 -0
- nodescraper/plugins/inband/package/analyzer_args.py +48 -0
- nodescraper/plugins/inband/package/package_analyzer.py +253 -0
- nodescraper/plugins/inband/package/package_collector.py +273 -0
- nodescraper/plugins/inband/package/package_plugin.py +43 -0
- nodescraper/plugins/inband/package/packagedata.py +41 -0
- nodescraper/plugins/inband/pcie/__init__.py +29 -0
- nodescraper/plugins/inband/pcie/analyzer_args.py +63 -0
- nodescraper/plugins/inband/pcie/pcie_analyzer.py +1081 -0
- nodescraper/plugins/inband/pcie/pcie_collector.py +690 -0
- nodescraper/plugins/inband/pcie/pcie_data.py +2017 -0
- nodescraper/plugins/inband/pcie/pcie_plugin.py +43 -0
- nodescraper/plugins/inband/process/__init__.py +25 -0
- nodescraper/plugins/inband/process/analyzer_args.py +45 -0
- nodescraper/plugins/inband/process/collector_args.py +31 -0
- nodescraper/plugins/inband/process/process_analyzer.py +91 -0
- nodescraper/plugins/inband/process/process_collector.py +115 -0
- nodescraper/plugins/inband/process/process_plugin.py +46 -0
- nodescraper/plugins/inband/process/processdata.py +34 -0
- nodescraper/plugins/inband/rocm/__init__.py +25 -0
- nodescraper/plugins/inband/rocm/analyzer_args.py +66 -0
- nodescraper/plugins/inband/rocm/rocm_analyzer.py +100 -0
- nodescraper/plugins/inband/rocm/rocm_collector.py +205 -0
- nodescraper/plugins/inband/rocm/rocm_plugin.py +43 -0
- nodescraper/plugins/inband/rocm/rocmdata.py +62 -0
- nodescraper/plugins/inband/storage/__init__.py +25 -0
- nodescraper/plugins/inband/storage/analyzer_args.py +38 -0
- nodescraper/plugins/inband/storage/collector_args.py +31 -0
- nodescraper/plugins/inband/storage/storage_analyzer.py +152 -0
- nodescraper/plugins/inband/storage/storage_collector.py +110 -0
- nodescraper/plugins/inband/storage/storage_plugin.py +44 -0
- nodescraper/plugins/inband/storage/storagedata.py +70 -0
- nodescraper/plugins/inband/sysctl/__init__.py +29 -0
- nodescraper/plugins/inband/sysctl/analyzer_args.py +67 -0
- nodescraper/plugins/inband/sysctl/sysctl_analyzer.py +81 -0
- nodescraper/plugins/inband/sysctl/sysctl_collector.py +101 -0
- nodescraper/plugins/inband/sysctl/sysctl_plugin.py +43 -0
- nodescraper/plugins/inband/sysctl/sysctldata.py +42 -0
- nodescraper/plugins/inband/syslog/__init__.py +28 -0
- nodescraper/plugins/inband/syslog/syslog_collector.py +121 -0
- nodescraper/plugins/inband/syslog/syslog_plugin.py +37 -0
- nodescraper/plugins/inband/syslog/syslogdata.py +46 -0
- nodescraper/plugins/inband/uptime/__init__.py +25 -0
- nodescraper/plugins/inband/uptime/uptime_collector.py +88 -0
- nodescraper/plugins/inband/uptime/uptime_plugin.py +37 -0
- nodescraper/plugins/inband/uptime/uptimedata.py +31 -0
- nodescraper/resultcollators/__init__.py +25 -0
- nodescraper/resultcollators/tablesummary.py +159 -0
- nodescraper/taskresulthooks/__init__.py +28 -0
- nodescraper/taskresulthooks/filesystemloghook.py +88 -0
- nodescraper/typeutils.py +171 -0
- nodescraper/utils.py +412 -0
|
@@ -0,0 +1,164 @@
|
|
|
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 typing import Optional
|
|
27
|
+
|
|
28
|
+
from nodescraper.base import InBandDataCollector
|
|
29
|
+
from nodescraper.connection.inband import TextFileArtifact
|
|
30
|
+
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily
|
|
31
|
+
from nodescraper.models import TaskResult
|
|
32
|
+
from nodescraper.utils import nice_rotated_name, shell_quote
|
|
33
|
+
|
|
34
|
+
from .collector_args import DmesgCollectorArgs
|
|
35
|
+
from .dmesgdata import DmesgData
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class DmesgCollector(InBandDataCollector[DmesgData, DmesgCollectorArgs]):
|
|
39
|
+
"""Read dmesg log"""
|
|
40
|
+
|
|
41
|
+
SUPPORTED_OS_FAMILY = {OSFamily.LINUX}
|
|
42
|
+
|
|
43
|
+
DATA_MODEL = DmesgData
|
|
44
|
+
|
|
45
|
+
CMD = "dmesg --time-format iso -x"
|
|
46
|
+
|
|
47
|
+
CMD_LOGS = (
|
|
48
|
+
r"ls -1 /var/log/dmesg* 2>/dev/null | grep -E '^/var/log/dmesg(\.[0-9]+(\.gz)?)?$' || true"
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
def _collect_dmesg_rotations(self):
|
|
52
|
+
"""Collect dmesg logs"""
|
|
53
|
+
list_res = self._run_sut_cmd(self.CMD_LOGS, sudo=True)
|
|
54
|
+
paths = [p.strip() for p in (list_res.stdout or "").splitlines() if p.strip()]
|
|
55
|
+
if not paths:
|
|
56
|
+
self._log_event(
|
|
57
|
+
category=EventCategory.OS,
|
|
58
|
+
description="No /var/log/dmesg files found (including rotations).",
|
|
59
|
+
data={"list_exit_code": list_res.exit_code},
|
|
60
|
+
priority=EventPriority.WARNING,
|
|
61
|
+
)
|
|
62
|
+
return 0
|
|
63
|
+
|
|
64
|
+
collected_logs, failed_logs = [], []
|
|
65
|
+
for p in paths:
|
|
66
|
+
qp = shell_quote(p)
|
|
67
|
+
if p.endswith(".gz"):
|
|
68
|
+
cmd = f"gzip -dc {qp} 2>/dev/null || zcat {qp} 2>/dev/null"
|
|
69
|
+
res = self._run_sut_cmd(cmd, sudo=True, log_artifact=False)
|
|
70
|
+
if res.exit_code == 0 and res.stdout is not None:
|
|
71
|
+
fname = nice_rotated_name(p, "dmesg")
|
|
72
|
+
self.logger.info("Collected dmesg log: %s", fname)
|
|
73
|
+
self.result.artifacts.append(
|
|
74
|
+
TextFileArtifact(filename=fname, contents=res.stdout)
|
|
75
|
+
)
|
|
76
|
+
collected_logs.append(
|
|
77
|
+
{"path": p, "as": fname, "bytes": len(res.stdout.encode("utf-8", "ignore"))}
|
|
78
|
+
)
|
|
79
|
+
else:
|
|
80
|
+
failed_logs.append(
|
|
81
|
+
{"path": p, "exit_code": res.exit_code, "stderr": res.stderr, "cmd": cmd}
|
|
82
|
+
)
|
|
83
|
+
else:
|
|
84
|
+
cmd = f"cat {qp}"
|
|
85
|
+
res = self._run_sut_cmd(cmd, sudo=True, log_artifact=False)
|
|
86
|
+
if res.exit_code == 0 and res.stdout is not None:
|
|
87
|
+
fname = nice_rotated_name(p, "dmesg")
|
|
88
|
+
self.logger.info("Collected dmesg log: %s", fname)
|
|
89
|
+
self.result.artifacts.append(
|
|
90
|
+
TextFileArtifact(filename=fname, contents=res.stdout)
|
|
91
|
+
)
|
|
92
|
+
collected_logs.append(
|
|
93
|
+
{"path": p, "as": fname, "bytes": len(res.stdout.encode("utf-8", "ignore"))}
|
|
94
|
+
)
|
|
95
|
+
else:
|
|
96
|
+
failed_logs.append(
|
|
97
|
+
{"path": p, "exit_code": res.exit_code, "stderr": res.stderr, "cmd": cmd}
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
if collected_logs:
|
|
101
|
+
self._log_event(
|
|
102
|
+
category=EventCategory.OS,
|
|
103
|
+
description="Collected dmesg rotated files",
|
|
104
|
+
data={"collected": collected_logs},
|
|
105
|
+
priority=EventPriority.INFO,
|
|
106
|
+
)
|
|
107
|
+
self.result.message = self.result.message or "dmesg rotated files collected"
|
|
108
|
+
|
|
109
|
+
if failed_logs:
|
|
110
|
+
self._log_event(
|
|
111
|
+
category=EventCategory.OS,
|
|
112
|
+
description="Some dmesg files could not be collected.",
|
|
113
|
+
data={"failed": failed_logs},
|
|
114
|
+
priority=EventPriority.WARNING,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
def _get_dmesg_content(self) -> str:
|
|
118
|
+
"""run dmesg command on system and return output
|
|
119
|
+
|
|
120
|
+
Returns:
|
|
121
|
+
str: dmesg output
|
|
122
|
+
"""
|
|
123
|
+
|
|
124
|
+
self.logger.info("Running dmesg command on system")
|
|
125
|
+
res = self._run_sut_cmd(self.CMD, sudo=True, log_artifact=False)
|
|
126
|
+
if res.exit_code != 0:
|
|
127
|
+
self._log_event(
|
|
128
|
+
category=EventCategory.OS,
|
|
129
|
+
description="Error reading dmesg",
|
|
130
|
+
data={"command": res.command, "exit_code": res.exit_code},
|
|
131
|
+
priority=EventPriority.ERROR,
|
|
132
|
+
console_log=True,
|
|
133
|
+
)
|
|
134
|
+
return res.stdout
|
|
135
|
+
|
|
136
|
+
def collect_data(
|
|
137
|
+
self,
|
|
138
|
+
args: Optional[DmesgCollectorArgs] = None,
|
|
139
|
+
) -> tuple[TaskResult, Optional[DmesgData]]:
|
|
140
|
+
"""Collect dmesg data from the system
|
|
141
|
+
|
|
142
|
+
Returns:
|
|
143
|
+
tuple[TaskResult, Optional[DmesgData]]: tuple containing the result of the task and the dmesg data if available
|
|
144
|
+
"""
|
|
145
|
+
if args is None:
|
|
146
|
+
args = DmesgCollectorArgs()
|
|
147
|
+
|
|
148
|
+
if args.skip_sudo:
|
|
149
|
+
self.result.message = "Skipping sudo plugin"
|
|
150
|
+
self.result.status = ExecutionStatus.NOT_RAN
|
|
151
|
+
return self.result, None
|
|
152
|
+
|
|
153
|
+
dmesg_content = self._get_dmesg_content()
|
|
154
|
+
if args.collect_rotated_logs:
|
|
155
|
+
self._collect_dmesg_rotations()
|
|
156
|
+
|
|
157
|
+
if dmesg_content:
|
|
158
|
+
dmesg_data = DmesgData(
|
|
159
|
+
dmesg_content=dmesg_content, skip_log_file=not args.log_dmesg_data
|
|
160
|
+
)
|
|
161
|
+
self.result.message = "Dmesg data collected"
|
|
162
|
+
return self.result, dmesg_data
|
|
163
|
+
|
|
164
|
+
return self.result, None
|
|
@@ -0,0 +1,44 @@
|
|
|
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 .analyzer_args import DmesgAnalyzerArgs
|
|
29
|
+
from .collector_args import DmesgCollectorArgs
|
|
30
|
+
from .dmesg_analyzer import DmesgAnalyzer
|
|
31
|
+
from .dmesg_collector import DmesgCollector
|
|
32
|
+
from .dmesgdata import DmesgData
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class DmesgPlugin(InBandDataPlugin[DmesgData, DmesgCollectorArgs, DmesgAnalyzerArgs]):
|
|
36
|
+
"""Plugin for collection and analysis of dmesg data"""
|
|
37
|
+
|
|
38
|
+
DATA_MODEL = DmesgData
|
|
39
|
+
|
|
40
|
+
COLLECTOR = DmesgCollector
|
|
41
|
+
|
|
42
|
+
ANALYZER = DmesgAnalyzer
|
|
43
|
+
|
|
44
|
+
COLLECTOR_ARGS = DmesgCollectorArgs
|
|
@@ -0,0 +1,116 @@
|
|
|
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
|
+
import os
|
|
27
|
+
import re
|
|
28
|
+
from typing import Union
|
|
29
|
+
|
|
30
|
+
from nodescraper.models import DataModel
|
|
31
|
+
from nodescraper.utils import get_unique_filename
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
class DmesgData(DataModel):
|
|
35
|
+
"""Data model for in band dmesg log"""
|
|
36
|
+
|
|
37
|
+
dmesg_content: str
|
|
38
|
+
skip_log_file: bool = False
|
|
39
|
+
|
|
40
|
+
@classmethod
|
|
41
|
+
def get_new_dmesg_lines(cls, current_dmesg: str, new_dmesg: str) -> str:
|
|
42
|
+
"""Get new dmesg lines that are in one output but not another
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
current_dmesg (str): initial dmesg output
|
|
46
|
+
new_dmesg (str): updated dmesg output
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
str: lines that are at the end of new_dmesg but not current_dmesg
|
|
50
|
+
"""
|
|
51
|
+
new_lines = []
|
|
52
|
+
new_dmesg_lines = new_dmesg.splitlines()
|
|
53
|
+
|
|
54
|
+
# reverse since any new lines will be at the end, so we want to start looking from there
|
|
55
|
+
new_dmesg_lines.reverse()
|
|
56
|
+
|
|
57
|
+
for line in new_dmesg_lines:
|
|
58
|
+
date = re.search(r"(\d{4}-\d+-\d+T\d+:\d+:\d+),(\d+[+-]\d+:\d+)", line)
|
|
59
|
+
if date and line in current_dmesg:
|
|
60
|
+
# only break for lines with a date that already exist in current dmesg
|
|
61
|
+
# lines with a date will be unique
|
|
62
|
+
break
|
|
63
|
+
|
|
64
|
+
new_lines.append(line)
|
|
65
|
+
|
|
66
|
+
# put new lines back in correct order since we appended in reverse
|
|
67
|
+
new_lines.reverse()
|
|
68
|
+
|
|
69
|
+
return ("\n").join(new_lines)
|
|
70
|
+
|
|
71
|
+
def merge_data(self, input_data: "DmesgData"):
|
|
72
|
+
"""Merge dmesg data with new input data
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
input_data (DmesgData): input dmesg data to merge with current dmesg data
|
|
76
|
+
"""
|
|
77
|
+
new_lines = self.get_new_dmesg_lines(input_data.dmesg_content, self.dmesg_content)
|
|
78
|
+
merged_data = input_data.dmesg_content.strip() + f"\n{new_lines.strip()}"
|
|
79
|
+
self.dmesg_content = merged_data
|
|
80
|
+
|
|
81
|
+
def log_model(self, log_path: str):
|
|
82
|
+
"""Log data model to a file
|
|
83
|
+
|
|
84
|
+
Args:
|
|
85
|
+
log_path (str): log path
|
|
86
|
+
"""
|
|
87
|
+
if self.skip_log_file:
|
|
88
|
+
return
|
|
89
|
+
log_name = os.path.join(log_path, get_unique_filename(log_path, "dmesg.log"))
|
|
90
|
+
with open(log_name, "w", encoding="utf-8") as log_file:
|
|
91
|
+
log_file.write(self.dmesg_content)
|
|
92
|
+
|
|
93
|
+
@classmethod
|
|
94
|
+
def import_model(cls, model_input: Union[dict, str]) -> "DmesgData":
|
|
95
|
+
"""Load dmesg data
|
|
96
|
+
|
|
97
|
+
Args:
|
|
98
|
+
model_input Union[dict, str]: dmesg file name or dmesg data dict
|
|
99
|
+
|
|
100
|
+
Raises:
|
|
101
|
+
ValueError: id model data has an invalid value
|
|
102
|
+
|
|
103
|
+
Returns:
|
|
104
|
+
DmesgDataModel: dmesg data model object
|
|
105
|
+
"""
|
|
106
|
+
|
|
107
|
+
if isinstance(model_input, dict):
|
|
108
|
+
return cls(**model_input)
|
|
109
|
+
|
|
110
|
+
if isinstance(model_input, str):
|
|
111
|
+
with open(model_input, "r", encoding="utf-8") as input_file:
|
|
112
|
+
dmesg_data = input_file.read()
|
|
113
|
+
|
|
114
|
+
return cls(dmesg_content=dmesg_data)
|
|
115
|
+
|
|
116
|
+
raise ValueError("Invalid input for model data")
|
|
@@ -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 .fabrics_plugin import FabricsPlugin
|
|
27
|
+
|
|
28
|
+
__all__ = ["FabricsPlugin"]
|