Skip to content

Commit 0bd03e6

Browse files
committed
added full dmidecode cmd to dimm collector + save to txt file
1 parent c3f229c commit 0bd03e6

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

nodescraper/plugins/inband/dimm/dimm_collector.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from typing import Optional
2727

2828
from nodescraper.base import InBandDataCollector
29+
from nodescraper.connection.inband import TextFileArtifact
2930
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily
3031
from nodescraper.models import TaskResult
3132

@@ -40,6 +41,7 @@ class DimmCollector(InBandDataCollector[DimmDataModel, DimmCollectorArgs]):
4041

4142
CMD_WINDOWS = "wmic memorychip get Capacity"
4243
CMD = """sh -c 'dmidecode -t 17 | tr -s " " | grep -v "Volatile\\|None\\|Module" | grep Size' 2>/dev/null"""
44+
CMD_DMIDECODE_FULL = "dmidecode"
4345

4446
def collect_data(
4547
self,
@@ -72,6 +74,25 @@ def collect_data(
7274
self.result.message = "Skipping sudo plugin"
7375
self.result.status = ExecutionStatus.NOT_RAN
7476
return self.result, None
77+
78+
# Collect full dmidecode output as artifact
79+
dmidecode_full_res = self._run_sut_cmd(self.CMD_DMIDECODE_FULL, sudo=True)
80+
if dmidecode_full_res.exit_code == 0 and dmidecode_full_res.stdout:
81+
self.result.artifacts.append(
82+
TextFileArtifact(filename="dmidecode.txt", contents=dmidecode_full_res.stdout)
83+
)
84+
else:
85+
self._log_event(
86+
category=EventCategory.OS,
87+
description="Could not collect full dmidecode output",
88+
data={
89+
"command": dmidecode_full_res.command,
90+
"exit_code": dmidecode_full_res.exit_code,
91+
"stderr": dmidecode_full_res.stderr,
92+
},
93+
priority=EventPriority.WARNING,
94+
)
95+
7596
res = self._run_sut_cmd(self.CMD, sudo=True)
7697
if res.exit_code == 0:
7798
total = 0

0 commit comments

Comments
 (0)