diff options
author | Jannik Schönartz | 2021-09-28 13:53:27 +0200 |
---|---|---|
committer | Jannik Schönartz | 2021-09-28 13:53:27 +0200 |
commit | cb88be7b4208a9cd27c43bd75dc44c953fa7d994 (patch) | |
tree | e2ea6b1ae59ee28ed50231798f6d80beb348ba13 | |
parent | [bas-hw-collect] Add some more checks for existing paths (diff) | |
download | systemd-init-cb88be7b4208a9cd27c43bd75dc44c953fa7d994.tar.gz systemd-init-cb88be7b4208a9cd27c43bd75dc44c953fa7d994.tar.xz systemd-init-cb88be7b4208a9cd27c43bd75dc44c953fa7d994.zip |
[bas-hw-collect] Add speed to network information
-rwxr-xr-x | modules.d/bas-hw-collect/scripts/collect_hw_info_json.py | 18 |
1 files 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 |