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,46 @@
|
|
|
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
|
+
|
|
28
|
+
from nodescraper.connection.inband.inband import TextFileArtifact
|
|
29
|
+
from nodescraper.models import DataModel
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SyslogData(DataModel):
|
|
33
|
+
"""Data model for in band syslog logs"""
|
|
34
|
+
|
|
35
|
+
syslog_logs: list[TextFileArtifact] = []
|
|
36
|
+
|
|
37
|
+
def log_model(self, log_path: str):
|
|
38
|
+
"""Log data model to a file
|
|
39
|
+
|
|
40
|
+
Args:
|
|
41
|
+
log_path (str): log path
|
|
42
|
+
"""
|
|
43
|
+
for artifact in self.syslog_logs:
|
|
44
|
+
log_name = os.path.join(log_path, artifact.filename)
|
|
45
|
+
with open(log_name, "w", encoding="utf-8") as log_file:
|
|
46
|
+
log_file.write(artifact.contents)
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
###############################################################################
|
|
@@ -0,0 +1,88 @@
|
|
|
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 re
|
|
27
|
+
from typing import Optional
|
|
28
|
+
|
|
29
|
+
from nodescraper.base import InBandDataCollector
|
|
30
|
+
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily
|
|
31
|
+
from nodescraper.models import TaskResult
|
|
32
|
+
|
|
33
|
+
from .uptimedata import UptimeDataModel
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class UptimeCollector(InBandDataCollector[UptimeDataModel, None]):
|
|
37
|
+
"""Collect last boot time and uptime from uptime command"""
|
|
38
|
+
|
|
39
|
+
DATA_MODEL = UptimeDataModel
|
|
40
|
+
|
|
41
|
+
SUPPORTED_OS_FAMILY: set[OSFamily] = {OSFamily.LINUX}
|
|
42
|
+
|
|
43
|
+
CMD = "uptime"
|
|
44
|
+
|
|
45
|
+
def collect_data(self, args=None) -> tuple[TaskResult, Optional[UptimeDataModel]]:
|
|
46
|
+
"""Collect uptime data from the system.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
tuple[TaskResult, Optional[UptimeDataModel]]: tuple containing the task result and uptime data model or None if failed.
|
|
50
|
+
"""
|
|
51
|
+
|
|
52
|
+
uptime_pattern = re.compile(
|
|
53
|
+
r"(?P<current_time>\d{2}:\d{2}:\d{2})\s+" r"up\s+(?P<uptime>.+?),\s+\d+\s+users?"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
res = self._run_sut_cmd(self.CMD)
|
|
57
|
+
|
|
58
|
+
if res.exit_code == 0:
|
|
59
|
+
line = res.stdout.strip()
|
|
60
|
+
match = uptime_pattern.match(line)
|
|
61
|
+
|
|
62
|
+
if match:
|
|
63
|
+
current_time = match.group("current_time")
|
|
64
|
+
uptime = match.group("uptime")
|
|
65
|
+
|
|
66
|
+
else:
|
|
67
|
+
self._log_event(
|
|
68
|
+
category=EventCategory.OS,
|
|
69
|
+
description="Error running uptime command",
|
|
70
|
+
data={"command": res.command, "exit_code": res.exit_code},
|
|
71
|
+
priority=EventPriority.ERROR,
|
|
72
|
+
console_log=True,
|
|
73
|
+
)
|
|
74
|
+
self.result.message = "Failed to run uptime command"
|
|
75
|
+
self.result.status = ExecutionStatus.EXECUTION_FAILURE
|
|
76
|
+
return self.result, None
|
|
77
|
+
|
|
78
|
+
uptime_data = UptimeDataModel(current_time=current_time, uptime=uptime)
|
|
79
|
+
|
|
80
|
+
self._log_event(
|
|
81
|
+
category=EventCategory.OS,
|
|
82
|
+
description="Uptime data collected",
|
|
83
|
+
data=uptime_data.model_dump(),
|
|
84
|
+
priority=EventPriority.INFO,
|
|
85
|
+
)
|
|
86
|
+
self.result.message = f"Uptime: {uptime}"
|
|
87
|
+
self.result.status = ExecutionStatus.OK
|
|
88
|
+
return self.result, uptime_data
|
|
@@ -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 .uptime_collector import UptimeCollector
|
|
29
|
+
from .uptimedata import UptimeDataModel
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class UptimePlugin(InBandDataPlugin[UptimeDataModel, None, None]):
|
|
33
|
+
"""Plugin for collection of system uptime data"""
|
|
34
|
+
|
|
35
|
+
DATA_MODEL = UptimeDataModel
|
|
36
|
+
|
|
37
|
+
COLLECTOR = UptimeCollector
|
|
@@ -0,0 +1,31 @@
|
|
|
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 UptimeDataModel(DataModel):
|
|
30
|
+
current_time: str
|
|
31
|
+
uptime: str
|
|
@@ -0,0 +1,25 @@
|
|
|
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
|
+
###############################################################################
|
|
@@ -0,0 +1,159 @@
|
|
|
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 textwrap import wrap
|
|
27
|
+
from typing import Optional
|
|
28
|
+
|
|
29
|
+
from nodescraper.interfaces import PluginResultCollator
|
|
30
|
+
from nodescraper.models import PluginResult, TaskResult
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class TableSummary(PluginResultCollator):
|
|
34
|
+
"""generate a summary of plugin results in a tabular format which will be logged using the logger instance"""
|
|
35
|
+
|
|
36
|
+
def collate_results(
|
|
37
|
+
self, plugin_results: list[PluginResult], connection_results: list[TaskResult], **kwargs
|
|
38
|
+
):
|
|
39
|
+
"""Collate the results into a summary table
|
|
40
|
+
|
|
41
|
+
Args:
|
|
42
|
+
plugin_results (list[PluginResult]): list of plugin results to collate
|
|
43
|
+
connection_results (list[TaskResult]): list of connection results to collate
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
def gen_str_table(
|
|
47
|
+
headers: list[str],
|
|
48
|
+
rows: list[list[Optional[str]]],
|
|
49
|
+
max_widths: Optional[dict[str, int]] = None,
|
|
50
|
+
) -> str:
|
|
51
|
+
"""Wrap cells
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
headers (list[str]): table header
|
|
55
|
+
rows (Optional[list[list[str]]]): table rows
|
|
56
|
+
max_widths (Optional[dict[str, int]], optional): width per col. Defaults to None.
|
|
57
|
+
|
|
58
|
+
Returns:
|
|
59
|
+
str: wrapped texed
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
max_widths = max_widths or {}
|
|
63
|
+
|
|
64
|
+
norm_rows: list[list[str]] = [
|
|
65
|
+
["" if c is None else str(c) for c in row] for row in rows
|
|
66
|
+
]
|
|
67
|
+
|
|
68
|
+
ncols = len(headers)
|
|
69
|
+
|
|
70
|
+
raw_widths: list[int] = [len(h) for h in headers]
|
|
71
|
+
for norm_row in norm_rows:
|
|
72
|
+
for i, cell in enumerate(norm_row):
|
|
73
|
+
for part in cell.splitlines() or [""]:
|
|
74
|
+
if len(part) > raw_widths[i]:
|
|
75
|
+
raw_widths[i] = len(part)
|
|
76
|
+
|
|
77
|
+
target_widths: list[int] = []
|
|
78
|
+
for i, h in enumerate(headers):
|
|
79
|
+
cap = max_widths.get(h)
|
|
80
|
+
if cap is None:
|
|
81
|
+
target_widths.append(raw_widths[i])
|
|
82
|
+
else:
|
|
83
|
+
target_widths.append(max(len(h), min(raw_widths[i], cap)))
|
|
84
|
+
|
|
85
|
+
wrapped_rows: list[list[list[str]]] = []
|
|
86
|
+
for norm_row in norm_rows:
|
|
87
|
+
wrapped_cells: list[list[str]] = []
|
|
88
|
+
for i, cell in enumerate(norm_row):
|
|
89
|
+
cell_lines: list[str] = []
|
|
90
|
+
paragraphs = cell.splitlines() or [""]
|
|
91
|
+
for para in paragraphs:
|
|
92
|
+
chunked = wrap(para, width=target_widths[i]) or [""]
|
|
93
|
+
cell_lines.extend(chunked)
|
|
94
|
+
wrapped_cells.append(cell_lines)
|
|
95
|
+
wrapped_rows.append(wrapped_cells)
|
|
96
|
+
|
|
97
|
+
col_widths: list[int] = []
|
|
98
|
+
for i in range(ncols):
|
|
99
|
+
widest_line = len(headers[i])
|
|
100
|
+
for wrow in wrapped_rows:
|
|
101
|
+
for line in wrow[i]:
|
|
102
|
+
if len(line) > widest_line:
|
|
103
|
+
widest_line = len(line)
|
|
104
|
+
col_widths.append(widest_line)
|
|
105
|
+
|
|
106
|
+
border = "+" + "+".join("-" * (w + 2) for w in col_widths) + "+"
|
|
107
|
+
|
|
108
|
+
def render_physical_row(parts: list[str]) -> str:
|
|
109
|
+
return "| " + " | ".join(p.ljust(w) for p, w in zip(parts, col_widths)) + " |"
|
|
110
|
+
|
|
111
|
+
table_lines: list[str] = [border, render_physical_row(headers), border]
|
|
112
|
+
for wrow in wrapped_rows:
|
|
113
|
+
height = max(len(cell_lines) for cell_lines in wrow)
|
|
114
|
+
for idx in range(height):
|
|
115
|
+
parts = [
|
|
116
|
+
(wrow[col][idx] if idx < len(wrow[col]) else "") for col in range(ncols)
|
|
117
|
+
]
|
|
118
|
+
table_lines.append(render_physical_row(parts))
|
|
119
|
+
table_lines.append(border)
|
|
120
|
+
return "\n".join(table_lines)
|
|
121
|
+
|
|
122
|
+
tables = ""
|
|
123
|
+
if connection_results:
|
|
124
|
+
conn_rows: list[list[Optional[str]]] = []
|
|
125
|
+
for connection_result in connection_results:
|
|
126
|
+
conn_rows.append(
|
|
127
|
+
[
|
|
128
|
+
connection_result.task,
|
|
129
|
+
connection_result.status.name,
|
|
130
|
+
connection_result.message,
|
|
131
|
+
]
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
table = gen_str_table(
|
|
135
|
+
["Connection", "Status", "Message"],
|
|
136
|
+
conn_rows,
|
|
137
|
+
max_widths={"Connection": 32, "Status": 16, "Message": 80},
|
|
138
|
+
)
|
|
139
|
+
tables += f"\n\n{table}"
|
|
140
|
+
|
|
141
|
+
if plugin_results:
|
|
142
|
+
plug_rows: list[list[Optional[str]]] = []
|
|
143
|
+
for plugin_result in plugin_results:
|
|
144
|
+
plug_rows.append(
|
|
145
|
+
[
|
|
146
|
+
plugin_result.source,
|
|
147
|
+
plugin_result.status.name,
|
|
148
|
+
plugin_result.message,
|
|
149
|
+
]
|
|
150
|
+
)
|
|
151
|
+
table = gen_str_table(
|
|
152
|
+
["Plugin", "Status", "Message"],
|
|
153
|
+
plug_rows,
|
|
154
|
+
max_widths={"Plugin": 32, "Status": 16, "Message": 80},
|
|
155
|
+
)
|
|
156
|
+
tables += f"\n\n{table}"
|
|
157
|
+
|
|
158
|
+
if tables:
|
|
159
|
+
self.logger.info("%s\n", tables)
|
|
@@ -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 .filesystemloghook import FileSystemLogHook
|
|
27
|
+
|
|
28
|
+
__all__ = ["FileSystemLogHook"]
|
|
@@ -0,0 +1,88 @@
|
|
|
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 json
|
|
27
|
+
import os
|
|
28
|
+
from typing import Optional
|
|
29
|
+
|
|
30
|
+
from nodescraper.connection.inband import BaseFileArtifact
|
|
31
|
+
from nodescraper.interfaces.taskresulthook import TaskResultHook
|
|
32
|
+
from nodescraper.models import DataModel, TaskResult
|
|
33
|
+
from nodescraper.utils import get_unique_filename, pascal_to_snake
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class FileSystemLogHook(TaskResultHook):
|
|
37
|
+
|
|
38
|
+
def __init__(self, log_base_path=None, **kwargs) -> None:
|
|
39
|
+
if log_base_path is None:
|
|
40
|
+
log_base_path = os.getcwd()
|
|
41
|
+
|
|
42
|
+
self.log_base_path = log_base_path
|
|
43
|
+
|
|
44
|
+
def process_result(self, task_result: TaskResult, data: Optional[DataModel] = None, **kwargs):
|
|
45
|
+
"""log task result to the filesystem
|
|
46
|
+
|
|
47
|
+
Args:
|
|
48
|
+
task_result (TaskResult): input task result
|
|
49
|
+
"""
|
|
50
|
+
log_path = self.log_base_path
|
|
51
|
+
if task_result.parent:
|
|
52
|
+
log_path = os.path.join(log_path, pascal_to_snake(task_result.parent))
|
|
53
|
+
if task_result.task:
|
|
54
|
+
log_path = os.path.join(log_path, pascal_to_snake(task_result.task))
|
|
55
|
+
|
|
56
|
+
os.makedirs(log_path, exist_ok=True)
|
|
57
|
+
|
|
58
|
+
with open(os.path.join(log_path, "result.json"), "w", encoding="utf-8") as log_file:
|
|
59
|
+
log_file.write(task_result.model_dump_json(exclude={"artifacts", "events"}, indent=2))
|
|
60
|
+
|
|
61
|
+
artifact_map = {}
|
|
62
|
+
for artifact in task_result.artifacts:
|
|
63
|
+
if isinstance(artifact, BaseFileArtifact):
|
|
64
|
+
log_name = get_unique_filename(log_path, artifact.filename)
|
|
65
|
+
artifact.log_model(log_path)
|
|
66
|
+
|
|
67
|
+
else:
|
|
68
|
+
name = f"{pascal_to_snake(artifact.__class__.__name__)}s"
|
|
69
|
+
if name in artifact_map:
|
|
70
|
+
artifact_map[name].append(artifact.model_dump(mode="json"))
|
|
71
|
+
else:
|
|
72
|
+
artifact_map[name] = [artifact.model_dump(mode="json")]
|
|
73
|
+
|
|
74
|
+
for name, artifacts in artifact_map.items():
|
|
75
|
+
log_name = get_unique_filename(log_path, f"{name}.json")
|
|
76
|
+
with open(os.path.join(log_path, log_name), "w", encoding="utf-8") as log_file:
|
|
77
|
+
json.dump(artifacts, log_file, indent=2)
|
|
78
|
+
|
|
79
|
+
if task_result.events:
|
|
80
|
+
event_log = get_unique_filename(log_path, "events.json")
|
|
81
|
+
events = [
|
|
82
|
+
event.model_dump(mode="json", exclude_none=True) for event in task_result.events
|
|
83
|
+
]
|
|
84
|
+
with open(os.path.join(log_path, event_log), "w", encoding="utf-8") as log_file:
|
|
85
|
+
json.dump(events, log_file, indent=2)
|
|
86
|
+
|
|
87
|
+
if data:
|
|
88
|
+
data.log_model(log_path)
|