Skip to content
This repository has been archived by the owner on Mar 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #13 from Showmax/ports_without_sfp_fix
Browse files Browse the repository at this point in the history
Do not run ethtool -m on interfaces that do not have an SFP inserted. This prevents errors from being spammed in syslog by the mlx5 driver.
  • Loading branch information
zloo authored Feb 24, 2023
2 parents 39f7529 + e047e2a commit 6d73202
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions ethtool-exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,8 @@ def update_basic_info(self, interface: str, info: InfoMetricFamily):
if not (data := self.run_ethtool(interface, "")):
return

self.ports_without_sfp = []

labels = {"device": interface}
for line in data.decode("utf-8").splitlines():
line = line.strip()
Expand All @@ -309,15 +311,16 @@ def update_basic_info(self, interface: str, info: InfoMetricFamily):
# drop lines without : - continuation of previous line
if not line or line.startswith("Settings for ") or ":" not in line:
continue

if not (key_val := self._parse_key_value_line(line)):
continue

key, value = key_val
key = key.strip().replace(" ", "_").lower()
if key not in self.basic_info_whitelist:
continue
# special handling for special values
if (key == "port") and (value == "Other" or value == "None"):
self.ports_without_sfp.append(interface)
continue
try:
if key == "speed":
value = self._decode_speed_value(value)
Expand Down Expand Up @@ -395,6 +398,9 @@ def update_xcvr_info(
:param sensors: Destination metric to put the sensors data in.
:param alarms: Destination metric to put the alarms data in.
"""

if interface in self.ports_without_sfp:
return
if not (data := self.run_ethtool(interface, "-m")):
# This usually happens when transceiver is missing
self.logger.info(f"Cannot get transceiver data for {interface}")
Expand Down

0 comments on commit 6d73202

Please sign in to comment.