30-sysinfo: don't show IPs for virtual interfaces
Not tested, may need tests and adjustments before the next release Closes #599
This commit is contained in:
parent
0c97a53823
commit
2d37a1ec3e
@ -90,11 +90,27 @@ function ambienttemp() {
|
||||
esac
|
||||
} # ambienttemp
|
||||
|
||||
#function get_ip_addresses() {
|
||||
# # return up to 2 IPv4 address(es) comma separated
|
||||
# hostname -I | tr " " "\n" | \
|
||||
# grep -E "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" | \
|
||||
# tail -n2 | sed ':a;N;$!ba;s/\n/,/g'
|
||||
#} # get_ip_addresses
|
||||
|
||||
function get_ip_addresses() {
|
||||
# return up to 2 IPv4 address(es) comma separated
|
||||
hostname -I | tr " " "\n" | \
|
||||
grep -E "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$" | \
|
||||
tail -n2 | sed ':a;N;$!ba;s/\n/,/g'
|
||||
local ips=()
|
||||
for f in /sys/class/net/*; do
|
||||
local intf=$(basename $f)
|
||||
# match only interface names starting with e (Ethernet), w (wireless), r (some Ralink drivers use ra<number> format)
|
||||
if [[ $intf =~ ^[ewr].* ]]; then
|
||||
local tmp=$(ip -4 addr show dev $intf | awk '/inet/ {print $2}' | cut -d'/' -f1)
|
||||
# add both name and IP - can be informative but becomes ugly with long persistent/predictable device names
|
||||
#[[ -n $tmp ]] && ips+=("$intf: $tmp")
|
||||
# add IP only
|
||||
[[ -n $tmp ]] && ips+=("$tmp")
|
||||
fi
|
||||
done
|
||||
echo "${ips[@]}"
|
||||
} # get_ip_addresses
|
||||
|
||||
function storage_info() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user