added option to show/hide disconnected nets

This commit is contained in:
pyr0ball 2023-03-08 14:13:04 -08:00
parent 5d829b31d8
commit 651f3d75ff
2 changed files with 18 additions and 4 deletions

2
PRbL

@ -1 +1 @@
Subproject commit 34698289a4662b104b2ff282ec177c666100f563 Subproject commit 07fde8af8b9747ad9b80832c07bd5901ca33db13

View file

@ -12,7 +12,7 @@
# Preferences: # Preferences:
# Network Adapter Preferences # Network Adapter Preferences
display_disconnected=true show_disconnected=true
# separate adapter names with '\|' ex. "lo\|tun0" # separate adapter names with '\|' ex. "lo\|tun0"
filtered_adapters="lo" filtered_adapters="lo"
@ -28,6 +28,11 @@ prbl_functons_req_ver=1.1.3
if [[ $(vercomp $functionsrev $prbl_functons_req_ver) == 2 ]] ; then if [[ $(vercomp $functionsrev $prbl_functons_req_ver) == 2 ]] ; then
warn "PRbL functions installed are lower than recommended ($prbl_functons_req_ver)" warn "PRbL functions installed are lower than recommended ($prbl_functons_req_ver)"
warn "Some features may not work as expected" warn "Some features may not work as expected"
else
if ! vercomp 1 1 ; then
warn "PRbL functions library is older than 1.1.3, please update!"
warn "Some features may not work as expected"
fi
fi fi
# Cache File Parameters # Cache File Parameters
@ -279,13 +284,16 @@ fi
declare -a adapters=() declare -a adapters=()
declare -a ips=() declare -a ips=()
declare -a macs=() declare -a macs=()
declare -a ifups=()
for device in $(ls /sys/class/net/ | grep -v "$filtered_adapters") ; do for device in $(ls /sys/class/net/ | grep -v "$filtered_adapters") ; do
adapters+=($device) adapters+=($device)
_ip=$(ip -f inet -o addr show $device | cut -d\ -f 7 | cut -d/ -f 1 | head -n 1) _ip=$(ip -f inet -o addr show $device | cut -d\ -f 7 | cut -d/ -f 1 | head -n 1)
if valid-ip $_ip ; then if valid-ip $_ip ; then
ips=(${ips[@]} "$_ip") ips=(${ips[@]} "$_ip")
ifups=(${ifups[@]} "up")
else else
ips=(${ips[@]} "${red}disconnected${dfl}") ips=(${ips[@]} "${red}disconnected${dfl}")
ifups=(${ifups[@]} "down")
fi fi
macs=(${macs[@]} "$(cat /sys/class/net/${device}/address)") macs=(${macs[@]} "$(cat /sys/class/net/${device}/address)")
done done
@ -325,7 +333,13 @@ boxline "${bld}${unl}Location:${dfl} ${grn}${unl}$location${dfl}"
boxline "" boxline ""
# Echo out network arrays # Echo out network arrays
for((i=0; i<"${#adapters[@]}"; i++ )); do for((i=0; i<"${#adapters[@]}"; i++ )); do
if [[ $show_disconnected == false ]] ; then
if [[ ${ifups[$i]} == up ]] ; then
boxline " ${adapters[$i]}: ${cyn}${ips[$i]}${dfl}\t| ${blu}${macs[$i]}${dfl}" boxline " ${adapters[$i]}: ${cyn}${ips[$i]}${dfl}\t| ${blu}${macs[$i]}${dfl}"
fi
else
boxline " ${adapters[$i]}: ${cyn}${ips[$i]}${dfl}\t| ${blu}${macs[$i]}${dfl}"
fi
done done
boxline " WAN IP: ${ylw}${wan_ip}${dfl}" boxline " WAN IP: ${ylw}${wan_ip}${dfl}"
boxline "" boxline ""
@ -337,7 +351,7 @@ boxline " System Load: ${load_averages}"
boxline " CPU Temp: ${lbl}${cputemp}${dfl} | Utilization: ${lrd}${cpu_util}%${dfl}" boxline " CPU Temp: ${lbl}${cputemp}${dfl} | Utilization: ${lrd}${cpu_util}%${dfl}"
boxline " Memory used/total: ${mem_usage}" boxline " Memory used/total: ${mem_usage}"
boxline " ${unl}Disk Info:${dfl}" boxline " ${unl}Disk Info:${dfl}"
boxline "${unl}$(printf '\t|%-4s\t%-4s\t%-4s\t%-4s\n' Usage Free Mount Logical)${dfl}" boxline "${unl}$(printf '\t|%-4s\t%-4s\t%-4s\t%-4s\n' Usage Free Mount Volumes)${dfl}"
for((i=0; i<"${#logicals[@]}"; i++ )); do for((i=0; i<"${#logicals[@]}"; i++ )); do
boxline "\t$(printf '|%-4s\t%-4s\t%-4s\t%-4s\n' ${usages[$i]} ${freespaces[$i]} ${mounts[$i]} ${logicals[$i]})" boxline "\t$(printf '|%-4s\t%-4s\t%-4s\t%-4s\n' ${usages[$i]} ${freespaces[$i]} ${mounts[$i]} ${logicals[$i]})"
done done