diff options
author | PMR <pmr@pmr-lander> | 2018-10-25 10:20:58 +0000 |
---|---|---|
committer | PMR <pmr@pmr-lander> | 2018-10-25 10:20:58 +0000 |
commit | 106231d081143161ce9e2529aa9962a23db14c1e (patch) | |
tree | 6e0ffab3e36a76786843c3ae8d64671b8453eb49 | |
parent | 120c9b4e4c5ee5d41290bccf3095dea818a2a579 (diff) | |
parent | c4f8393820217da9f9e745cf340002d07516483e (diff) |
Merge #357765 from ~jocave/plainbox-provider-checkbox:network-info-ipv6-fix
-rwxr-xr-x | bin/network_info | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/bin/network_info b/bin/network_info index 7dbe609..d3ff5df 100755 --- a/bin/network_info +++ b/bin/network_info @@ -40,9 +40,10 @@ def get_ip_address(interface): def get_ipv6_address(interface): - cmd = ['/sbin/ip', '-6', 'addr', 'show', 'dev', interface] + cmd = ['/sbin/ip', '-6', '-o', 'addr', 'show', + 'dev', interface, 'scope', 'link'] proc = subprocess.check_output(cmd, universal_newlines=True) - ipaddr = proc.split()[8].strip() + ipaddr = proc.split()[3].strip() return ipaddr @@ -57,6 +58,7 @@ def get_mac_address(interface): return address + def get_speed(interface): speed_file = os.path.join(SYS_PATH, interface, 'speed') @@ -79,15 +81,16 @@ def main(args): except IOError: print("IPv4: n/a") try: - print("IPv6: %s" % get_ipv6_address(interface)) + print("IPv6 (link local): %s" % get_ipv6_address(interface)) except IOError: - print("IPv6: n/a") + print("IPv6 (link local): n/a") except: - print("IPv6: n/a") + print("IPv6 (link local): n/a") print("MAC: %s" % get_mac_address(interface)) print("Connect Speed: %s\n" % get_speed(interface)) return 0 + if __name__ == "__main__": sys.exit(main(sys.argv[1:])) |