Skip to content

Commit d54fb25

Browse files
Jaspal SinghJaspal Singh
authored andcommitted
journal techsupport changes
1 parent c53a68d commit d54fb25

File tree

3 files changed

+60
-6
lines changed

3 files changed

+60
-6
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 typing import Optional
28+
29+
from nodescraper.models import CollectorArgs
30+
31+
32+
class JournalCollectorArgs(CollectorArgs):
33+
boot: Optional[int] = None

nodescraper/plugins/inband/journal/journal_collector.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,28 +23,40 @@
2323
# SOFTWARE.
2424
#
2525
###############################################################################
26+
from typing import Optional
2627

2728
from nodescraper.base import InBandDataCollector
2829
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus, OSFamily
2930
from nodescraper.models import TaskResult
3031

32+
from .collector_args import JournalCollectorArgs
3133
from .journaldata import JournalData
3234

3335

34-
class JournalCollector(InBandDataCollector[JournalData, None]):
36+
class JournalCollector(InBandDataCollector[JournalData, JournalCollectorArgs]):
3537
"""Read journal log via journalctl."""
3638

3739
SUPPORTED_OS_FAMILY = {OSFamily.LINUX}
3840
DATA_MODEL = JournalData
3941

40-
def _read_with_journalctl(self):
42+
def _read_with_journalctl(self, args: Optional[JournalCollectorArgs] = None):
4143
"""Read journal logs using journalctl
4244
4345
Returns:
4446
str|None: system journal read
4547
"""
46-
cmd = "journalctl --no-pager --system --output=short-iso"
48+
boot_arg = ""
49+
50+
if args is not None:
51+
try:
52+
# Accept ints or numeric strings
53+
boot_arg = f" -b {args.boot}"
54+
except (TypeError, ValueError):
55+
pass
56+
57+
cmd = f"journalctl --no-pager{boot_arg} --system --output=short-iso"
4758
res = self._run_sut_cmd(cmd, sudo=True, log_artifact=False, strip=False)
59+
self.result.message = cmd
4860

4961
if res.exit_code != 0:
5062
self._log_event(
@@ -60,7 +72,10 @@ def _read_with_journalctl(self):
6072

6173
return res.stdout
6274

63-
def collect_data(self, args=None) -> tuple[TaskResult, JournalData | None]:
75+
def collect_data(
76+
self,
77+
args: Optional[JournalCollectorArgs] = None,
78+
) -> tuple[TaskResult, JournalData | None]:
6479
"""Collect journal logs
6580
6681
Args:
@@ -69,7 +84,10 @@ def collect_data(self, args=None) -> tuple[TaskResult, JournalData | None]:
6984
Returns:
7085
tuple[TaskResult, JournalData | None]: Tuple of results and data model or none.
7186
"""
72-
journal_log = self._read_with_journalctl()
87+
if args is None:
88+
args = JournalCollectorArgs()
89+
90+
journal_log = self._read_with_journalctl(args)
7391
if journal_log:
7492
data = JournalData(journal_log=journal_log)
7593
self.result.message = self.result.message or "Journal data collected"

nodescraper/plugins/inband/journal/journal_plugin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@
2525
###############################################################################
2626
from nodescraper.base import InBandDataPlugin
2727

28+
from .collector_args import JournalCollectorArgs
2829
from .journal_collector import JournalCollector
2930
from .journaldata import JournalData
3031

3132

32-
class JournalPlugin(InBandDataPlugin[JournalData, None, None]):
33+
class JournalPlugin(InBandDataPlugin[JournalData, JournalCollectorArgs, None]):
3334
"""Plugin for collection of journal data"""
3435

3536
DATA_MODEL = JournalData
3637

3738
COLLECTOR = JournalCollector
39+
40+
COLLECTOR_ARGS = JournalCollectorArgs

0 commit comments

Comments
 (0)