Skip to content

Commit 0e5cd17

Browse files
committed
Merge branch 'development' into alex_syslog
2 parents d86215f + d44d952 commit 0e5cd17

File tree

8 files changed

+456
-0
lines changed

8 files changed

+456
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
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 .analyzer_args import SysctlAnalyzerArgs
27+
from .sysctl_plugin import SysctlPlugin
28+
29+
__all__ = ["SysctlPlugin", "SysctlAnalyzerArgs"]
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
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.models import AnalyzerArgs
29+
from nodescraper.plugins.inband.sysctl.sysctldata import SysctlDataModel
30+
31+
32+
class SysctlAnalyzerArgs(AnalyzerArgs):
33+
exp_vm_swappiness: Optional[int] = None
34+
exp_vm_numa_balancing: Optional[int] = None
35+
exp_vm_oom_kill_allocating_task: Optional[int] = None
36+
exp_vm_compaction_proactiveness: Optional[int] = None
37+
exp_vm_compact_unevictable_allowed: Optional[int] = None
38+
exp_vm_extfrag_threshold: Optional[int] = None
39+
exp_vm_zone_reclaim_mode: Optional[int] = None
40+
exp_vm_dirty_background_ratio: Optional[int] = None
41+
exp_vm_dirty_ratio: Optional[int] = None
42+
exp_vm_dirty_writeback_centisecs: Optional[int] = None
43+
exp_kernel_numa_balancing: Optional[int] = None
44+
45+
@classmethod
46+
def build_from_model(cls, datamodel: SysctlDataModel) -> "SysctlAnalyzerArgs":
47+
"""build analyzer args from data model
48+
49+
Args:
50+
datamodel (SysctlDataModel): data model for plugin
51+
52+
Returns:
53+
SysctlAnalyzerArgs: instance of analyzer args class
54+
"""
55+
return cls(
56+
exp_vm_swappiness=datamodel.vm_swappiness,
57+
exp_vm_numa_balancing=datamodel.vm_numa_balancing,
58+
exp_vm_oom_kill_allocating_task=datamodel.vm_oom_kill_allocating_task,
59+
exp_vm_compaction_proactiveness=datamodel.vm_compaction_proactiveness,
60+
exp_vm_compact_unevictable_allowed=datamodel.vm_compact_unevictable_allowed,
61+
exp_vm_extfrag_threshold=datamodel.vm_extfrag_threshold,
62+
exp_vm_zone_reclaim_mode=datamodel.vm_zone_reclaim_mode,
63+
exp_vm_dirty_background_ratio=datamodel.vm_dirty_background_ratio,
64+
exp_vm_dirty_ratio=datamodel.vm_dirty_ratio,
65+
exp_vm_dirty_writeback_centisecs=datamodel.vm_dirty_writeback_centisecs,
66+
exp_kernel_numa_balancing=datamodel.kernel_numa_balancing,
67+
)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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.enums import EventCategory, EventPriority, ExecutionStatus
30+
from nodescraper.interfaces import DataAnalyzer
31+
from nodescraper.models import TaskResult
32+
33+
from .analyzer_args import SysctlAnalyzerArgs
34+
from .sysctldata import SysctlDataModel
35+
36+
37+
class SysctlAnalyzer(DataAnalyzer[SysctlDataModel, SysctlAnalyzerArgs]):
38+
"""Check sysctl matches expected sysctl details"""
39+
40+
DATA_MODEL = SysctlDataModel
41+
42+
def analyze_data(
43+
self, data: SysctlDataModel, args: Optional[SysctlAnalyzerArgs] = None
44+
) -> TaskResult:
45+
"""Analyze the Sysctl data against expected Sysctl values."""
46+
mismatches = {}
47+
48+
if not args:
49+
args = SysctlAnalyzerArgs()
50+
51+
for exp_field_name, expected_value in args.model_dump(exclude_unset=True).items():
52+
53+
data_field_name = exp_field_name.removeprefix("exp_")
54+
actual_value = getattr(data, data_field_name, None)
55+
56+
if actual_value is None:
57+
mismatches[data_field_name] = {"expected": expected_value, "actual": "missing"}
58+
elif actual_value != expected_value:
59+
mismatches[data_field_name] = {"expected": expected_value, "actual": actual_value}
60+
61+
if mismatches:
62+
self.result.status = ExecutionStatus.ERROR
63+
self.result.message = f"{len(mismatches)} sysctl parameter(s) mismatched."
64+
self.result.message = "Sysctl parameters mismatch detected."
65+
self._log_event(
66+
category=EventCategory.OS,
67+
description="Sysctl mismatch detected",
68+
data=mismatches,
69+
priority=EventPriority.ERROR,
70+
console_log=True,
71+
)
72+
else:
73+
self._log_event(
74+
category=EventCategory.OS,
75+
description="All expected sysctl parameters matched",
76+
priority=EventPriority.INFO,
77+
console_log=True,
78+
)
79+
self.result.status = ExecutionStatus.OK
80+
self.result.message = "All expected sysctl parameters match."
81+
82+
return self.result
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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 .sysctldata import SysctlDataModel
32+
33+
34+
class SysctlCollector(InBandDataCollector[SysctlDataModel, None]):
35+
"""Collect sysctl kernel VM settings."""
36+
37+
DATA_MODEL = SysctlDataModel
38+
39+
def collect_data(
40+
self,
41+
args=None,
42+
) -> tuple[TaskResult, SysctlDataModel | None]:
43+
"""Collect sysctl VM tuning values from the system."""
44+
values = {}
45+
46+
if self.system_info.os_family == OSFamily.WINDOWS:
47+
self._log_event(
48+
category=EventCategory.OS,
49+
description="Windows is not supported for sysctl collection.",
50+
priority=EventPriority.WARNING,
51+
console_log=True,
52+
)
53+
return self.result, None
54+
55+
for field_name in SysctlDataModel.model_fields:
56+
sysctl_key = field_name.replace("_", ".", 1)
57+
res = self._run_sut_cmd(f"sysctl -n {sysctl_key}")
58+
59+
if res.exit_code == 0:
60+
try:
61+
values[field_name] = int(res.stdout.strip())
62+
except ValueError:
63+
self._log_event(
64+
category=EventCategory.OS,
65+
description=f"Invalid integer value for {sysctl_key}",
66+
data={"stdout": res.stdout},
67+
priority=EventPriority.ERROR,
68+
console_log=True,
69+
)
70+
else:
71+
self._log_event(
72+
category=EventCategory.OS,
73+
description=f"Error checking Linux system setting : {sysctl_key}",
74+
data={"system_setting": sysctl_key, "exit_code": res.exit_code},
75+
priority=EventPriority.WARNING,
76+
console_log=True,
77+
)
78+
79+
if values:
80+
sysctl_data = SysctlDataModel(**values)
81+
self._log_event(
82+
category="OS",
83+
description="Sysctl settings read",
84+
data=sysctl_data.model_dump(),
85+
priority=EventPriority.INFO,
86+
)
87+
self.result.message = "SYSCTL data collected"
88+
self.result.status = ExecutionStatus.OK
89+
else:
90+
sysctl_data = None
91+
self._log_event(
92+
category=EventCategory.OS,
93+
description="Sysctl settings not read",
94+
priority=EventPriority.CRITICAL,
95+
)
96+
self.result.message = "Sysctl settings not read"
97+
self.result.status = ExecutionStatus.ERROR
98+
99+
return self.result, sysctl_data
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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 SysctlAnalyzerArgs
29+
from .sysctl_analyzer import SysctlAnalyzer
30+
from .sysctl_collector import SysctlCollector
31+
from .sysctldata import SysctlDataModel
32+
33+
34+
class SysctlPlugin(InBandDataPlugin[SysctlDataModel, None, SysctlAnalyzerArgs]):
35+
"""Plugin for collection and analysis of BIOS data"""
36+
37+
DATA_MODEL = SysctlDataModel
38+
39+
COLLECTOR = SysctlCollector
40+
41+
ANALYZER = SysctlAnalyzer
42+
43+
ANALYZER_ARGS = SysctlAnalyzerArgs
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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.models import DataModel
29+
30+
31+
class SysctlDataModel(DataModel):
32+
vm_swappiness: Optional[int] = None
33+
vm_numa_balancing: Optional[int] = None
34+
vm_oom_kill_allocating_task: Optional[int] = None
35+
vm_compaction_proactiveness: Optional[int] = None
36+
vm_compact_unevictable_allowed: Optional[int] = None
37+
vm_extfrag_threshold: Optional[int] = None
38+
vm_zone_reclaim_mode: Optional[int] = None
39+
vm_dirty_background_ratio: Optional[int] = None
40+
vm_dirty_ratio: Optional[int] = None
41+
vm_dirty_writeback_centisecs: Optional[int] = None
42+
kernel_numa_balancing: Optional[int] = None

0 commit comments

Comments
 (0)