Skip to content

Commit 518e932

Browse files
committed
removed ethtool blanket analyzer arg
1 parent 4d25ebb commit 518e932

7 files changed

Lines changed: 19 additions & 426 deletions

File tree

nodescraper/plugins/inband/network/analyzer_args.py

Lines changed: 0 additions & 40 deletions
This file was deleted.

nodescraper/plugins/inband/network/ethtool_vendor.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -675,16 +675,12 @@ class Cx7EthtoolStatistics(BaseModel):
675675
Cx7EthtoolStatistics,
676676
]
677677

678-
VendorEthtoolStatisticsCls = Union[
679-
type[PollaraEthtoolStatistics],
680-
type[Thor2EthtoolStatistics],
681-
type[Cx7EthtoolStatistics],
682-
]
678+
679+
VendorEthtoolStatisticsCls = type[VendorEthtoolStatisticsModel]
683680

684681

685-
# Map ifname prefixes to vendor-specific statistic models
686-
# If netdev is ens, use Cx7
687-
# If netdev is benic, check if it starts with ionic or bnxt to determine if it's Pollara or Thor2
682+
# Map kernel driver name prefixes (from `ethtool -i`) to vendor-specific models
683+
# ionic -> Pollara, bnxt -> Thor2, mlx -> ConnectX-7
688684
VENDOR_PREFIX_MAP: dict[str, VendorEthtoolStatisticsCls] = {
689685
"ionic": PollaraEthtoolStatistics,
690686
"bnxt": Thor2EthtoolStatistics,

nodescraper/plugins/inband/network/network_analyzer.py

Lines changed: 8 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,25 @@
2424
#
2525
###############################################################################
2626
import re
27-
from typing import Optional
2827

29-
from nodescraper.base.regexanalyzer import ErrorRegex, RegexAnalyzer
28+
from nodescraper.base.regexanalyzer import RegexAnalyzer
3029
from nodescraper.enums import EventCategory, EventPriority, ExecutionStatus
3130
from nodescraper.models import TaskResult
3231

33-
from .analyzer_args import NetworkAnalyzerArgs
3432
from .networkdata import NetworkDataModel
3533

3634

37-
class NetworkAnalyzer(RegexAnalyzer[NetworkDataModel, NetworkAnalyzerArgs]):
35+
class NetworkAnalyzer(RegexAnalyzer[NetworkDataModel, None]):
3836
"""Check network statistics for errors."""
3937

4038
DATA_MODEL = NetworkDataModel
4139

42-
# No built-in regex patterns: RDMA-scoped counter classification lives in the vendor
43-
# ethtool models (ethtool_vendor.py). This list is only extended by user-supplied
44-
# NetworkAnalyzerArgs.error_regex patterns.
45-
ERROR_REGEX: list[ErrorRegex] = []
46-
47-
def analyze_data(
48-
self, data: NetworkDataModel, args: Optional[NetworkAnalyzerArgs] = None
49-
) -> TaskResult:
50-
"""Analyze ethtool -S statistics via RDMA-scoped vendor models and any user-supplied regex.
40+
def analyze_data(self, data: NetworkDataModel, args=None) -> TaskResult:
41+
"""Analyze ethtool -S statistics via RDMA-scoped vendor models.
5142
5243
Args:
53-
data: Network data model with ethtool_info and/or ethtool_statistics.
54-
args: Optional analyzer arguments with custom error regex support.
44+
data: Network data model with ethtool_statistics.
45+
args: Unused; retained for analyzer interface compatibility.
5546
5647
Returns:
5748
TaskResult with OK, WARNING (no devices, or only warning-tier counters), or ERROR.
@@ -61,52 +52,6 @@ def analyze_data(
6152
self.result.status = ExecutionStatus.WARNING
6253
return self.result
6354

64-
if not args:
65-
args = NetworkAnalyzerArgs()
66-
67-
final_error_regex = self._convert_and_extend_error_regex(args.error_regex, self.ERROR_REGEX)
68-
69-
regex_error = False
70-
regex_warning = False
71-
for interface_name, ethtool_info in data.ethtool_info.items():
72-
matches_on_interface: list[tuple[str, int, EventPriority]] = []
73-
for stat_name, stat_value in ethtool_info.statistics.items():
74-
for error_regex_obj in final_error_regex:
75-
if error_regex_obj.regex.match(stat_name):
76-
try:
77-
value = int(stat_value)
78-
except (ValueError, TypeError):
79-
break
80-
81-
if value > 0:
82-
matches_on_interface.append(
83-
(stat_name, value, error_regex_obj.event_priority)
84-
)
85-
break
86-
87-
if matches_on_interface:
88-
has_error = any(
89-
priority == EventPriority.ERROR for _, _, priority in matches_on_interface
90-
)
91-
if has_error:
92-
regex_error = True
93-
else:
94-
regex_warning = True
95-
priority = EventPriority.ERROR if has_error else EventPriority.WARNING
96-
severity = "error" if has_error else "warning"
97-
match_names = [match[0] for match in matches_on_interface]
98-
matches_data = {name: value for name, value, _ in matches_on_interface}
99-
self._log_event(
100-
category=EventCategory.NETWORK,
101-
description=f"Network {severity} detected on {interface_name}: [{', '.join(match_names)}]",
102-
data={
103-
"interface": interface_name,
104-
"errors": matches_data,
105-
},
106-
priority=priority,
107-
console_log=True,
108-
)
109-
11055
vendor_error = False
11156
vendor_warning = False
11257
vendor_error_fields: set[str] = set()
@@ -214,10 +159,10 @@ def analyze_data(
214159
", ".join(sorted(vendor_queue_warning_fields)),
215160
)
216161

217-
if regex_error or vendor_error:
162+
if vendor_error:
218163
self.result.message = "Network errors detected in statistics"
219164
self.result.status = ExecutionStatus.ERROR
220-
elif regex_warning or vendor_warning:
165+
elif vendor_warning:
221166
self.result.message = "Network warning counters non-zero in statistics"
222167
self.result.status = ExecutionStatus.WARNING
223168
else:

nodescraper/plugins/inband/network/network_collector.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,9 @@ def _collect_ethtool_statistic(self, netdev: str, driver: str) -> Optional[Ethto
529529
530530
The vendor model is selected by matching ``driver`` (from ``ethtool -i``)
531531
against the known vendor prefixes in ``VENDOR_PREFIX_MAP``.
532+
533+
Returns:
534+
EthtoolStatistics, or None on command failure.
532535
"""
533536
cmd_s = self.CMD_ETHTOOL_S_TEMPLATE.format(interface=netdev)
534537
res = self._run_sut_cmd(cmd_s, sudo=True)
@@ -613,11 +616,7 @@ def _collect_ethtool_statistics(
613616
"""Collect ethtool -S for vendor netdevs discovered from `ip addr`.
614617
615618
Each interface's driver is resolved via `ethtool -i`; only interfaces whose
616-
driver matches a known vendor prefix (see VENDOR_PREFIX_MAP) are collected. The
617-
matched driver selects the respective vendor data model used to parse the
618-
`ethtool -S` counters. Interfaces without a known vendor driver (lo, docker,
619-
veth, ...) are skipped, which avoids noisy `ethtool -S` failures. This does not
620-
depend on RDMA.
619+
driver matches a known vendor prefix (see VENDOR_PREFIX_MAP) are collected.
621620
622621
Args:
623622
interfaces: Interfaces discovered from `ip addr` to consider.

nodescraper/plugins/inband/network/network_plugin.py

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

28-
from .analyzer_args import NetworkAnalyzerArgs
2928
from .collector_args import NetworkCollectorArgs
3029
from .network_analyzer import NetworkAnalyzer
3130
from .network_collector import NetworkCollector
3231
from .networkdata import NetworkDataModel
3332

3433

35-
class NetworkPlugin(InBandDataPlugin[NetworkDataModel, NetworkCollectorArgs, NetworkAnalyzerArgs]):
34+
class NetworkPlugin(InBandDataPlugin[NetworkDataModel, NetworkCollectorArgs, None]):
3635
"""Plugin for collection of network configuration data"""
3736

3837
DATA_MODEL = NetworkDataModel
@@ -42,5 +41,3 @@ class NetworkPlugin(InBandDataPlugin[NetworkDataModel, NetworkCollectorArgs, Net
4241
COLLECTOR_ARGS = NetworkCollectorArgs
4342

4443
ANALYZER = NetworkAnalyzer
45-
46-
ANALYZER_ARGS = NetworkAnalyzerArgs

nodescraper/plugins/inband/network/networkdata.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ class EthtoolInfo(BaseModel):
105105
port: Optional[str] = None # Port type (e.g., "Twisted Pair")
106106
auto_negotiation: Optional[str] = None # Auto-negotiation status (e.g., "on", "off")
107107
link_detected: Optional[str] = None # Link detection status (e.g., "yes", "no")
108-
# ethtool -S (statistics) output: parsed key-value for error/health analysis
109-
statistics: Dict[str, str] = Field(default_factory=dict)
110108

111109

112110
class NetworkDataModel(DataModel):
@@ -116,9 +114,7 @@ class NetworkDataModel(DataModel):
116114
routes: List[Route] = Field(default_factory=list)
117115
rules: List[RoutingRule] = Field(default_factory=list)
118116
neighbors: List[Neighbor] = Field(default_factory=list)
119-
ethtool_info: Dict[str, EthtoolInfo] = Field(
120-
default_factory=dict
121-
) # Interface name -> EthtoolInfo mapping
117+
ethtool_info: Dict[str, EthtoolInfo] = Field(default_factory=dict)
122118
# ethtool -S vendor-parsed counters for netdevs whose driver matches a known vendor
123119
ethtool_netdevs: List[str] = Field(default_factory=list)
124120
ethtool_statistics: List[EthtoolStatistics] = Field(default_factory=list)

0 commit comments

Comments
 (0)