Skip to content

Commit

Permalink
statd: allow ethtool rmon counters readout to fail
Browse files Browse the repository at this point in the history
In e373398 we restored statd suport for checking for faults in yanger at
runtime.  This in turn broke CLI "show interfaces" support on the little
NanoPi R2S because ethtool cannot read counters in JSON format on it.

This patch catches the subprocess exception, allowing this particular
call to ethtool to fail with empty result.  The only difference from
before e373398 is that run_json_cmd() will log an error that ethtool
failed, for every interface it is called on.

Signed-off-by: Joachim Wiberg <[email protected]>
  • Loading branch information
troglobit committed Oct 9, 2024
1 parent 979583e commit c569119
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/statd/python/yanger/yanger.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,12 +726,15 @@ def add_ip_addr(ifname, iface_in, iface_out):


def add_ethtool_groups(ifname, iface_out):
"""Fetch interface counters from kernel"""

data = run_json_cmd(['ethtool', '--json', '-S', ifname, '--all-groups'],
f"ethtool-groups-{ifname}.json")
if len(data) != 1:
logger.warning(f"{ifname}: no counters available, skipping.")
"""Fetch interface counters from kernel (need new JSON format!)"""
cmd = ['ethtool', '--json', '-S', ifname, '--all-groups']
try:
data = run_json_cmd(cmd, f"ethtool-groups-{ifname}.json")
if len(data) != 1:
logger.warning("%s: no counters available, skipping.", ifname)
return
except subprocess.CalledProcessError:
# Allow comand to fail, not all NICs support --json yet
return

iface_in = data[0]
Expand Down

0 comments on commit c569119

Please sign in to comment.