From cb88be7b4208a9cd27c43bd75dc44c953fa7d994 Mon Sep 17 00:00:00 2001 From: Jannik Schönartz Date: Tue, 28 Sep 2021 13:53:27 +0200 Subject: [bas-hw-collect] Add speed to network information --- .../bas-hw-collect/scripts/collect_hw_info_json.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/modules.d/bas-hw-collect/scripts/collect_hw_info_json.py b/modules.d/bas-hw-collect/scripts/collect_hw_info_json.py index 18326b2b..ea02c3ae 100755 --- a/modules.d/bas-hw-collect/scripts/collect_hw_info_json.py +++ b/modules.d/bas-hw-collect/scripts/collect_hw_info_json.py @@ -173,10 +173,10 @@ def get_ip(): return result def get_net_fallback(): - netdir = '/sys/class/net' + netdir = '/sys/class/net/' result = {} - # Get MAC address + # Get MAC address and speed if path.exists(netdir): interfaces = run_subprocess('ls ' + netdir).split('\n') for interface in interfaces: @@ -184,9 +184,17 @@ def get_net_fallback(): if interface == 'lo' or interface == '': continue net = {} - net['mac'] = run_subprocess('cat /sys/class/net/' + interface + '/address') - if net['mac'].endswith('\n'): - net['mac'] = net['mac'][:-1] + speed = run_subprocess('cat ' + netdir + interface + '/speed') + if isinstance(speed, str) and speed.endswith('\n'): + net['speed'] = speed[:-1] + + duplex = run_subprocess('cat ' + netdir + interface + '/duplex') + if isinstance(duplex, str) and duplex.endswith('\n'): + net['duplex'] = duplex[:-1] + + mac = run_subprocess('cat ' + netdir + interface + '/address') + if isinstance(mac, str) and mac.endswith('\n'): + net['mac'] = mac[:-1] result[interface] = net # Get IP address -- cgit v1.2.3-55-g7522