statd: allow ethtool rmon counters readout to fail

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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2024-10-10 23:55:13 +02:00
parent 374d24a547
commit 9a3f7d44c4
+9 -6
View File
@@ -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]