mirror of
https://github.com/smxi/inxi.git
synced 2024-11-17 00:31:19 +00:00
new feature, in stable trunk, -n, shows advanced network card information.
This will probably be modified quite a bit over time so it's a 1.4.80 to start, once it's stable, it will be 1.5.0 release.
This commit is contained in:
parent
3213f8d1ed
commit
c7079c5f00
101
inxi
101
inxi
|
@ -1,8 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
########################################################################
|
########################################################################
|
||||||
#### Script Name: inxi
|
#### Script Name: inxi
|
||||||
#### version: 1.4.24
|
#### version: 1.4.80
|
||||||
#### Date: April 20 2011
|
#### Date: April 24 2011
|
||||||
########################################################################
|
########################################################################
|
||||||
#### SPECIAL THANKS
|
#### SPECIAL THANKS
|
||||||
########################################################################
|
########################################################################
|
||||||
|
@ -223,6 +223,7 @@ B_ROOT='false'
|
||||||
B_RUNNING_IN_SHELL='false'
|
B_RUNNING_IN_SHELL='false'
|
||||||
# this sets the debug buffer
|
# this sets the debug buffer
|
||||||
B_SCRIPT_UP='false'
|
B_SCRIPT_UP='false'
|
||||||
|
B_SHOW_ADVANCED_NETWORK='false'
|
||||||
# Show sound card data
|
# Show sound card data
|
||||||
B_SHOW_AUDIO='false'
|
B_SHOW_AUDIO='false'
|
||||||
B_SHOW_CPU='false'
|
B_SHOW_CPU='false'
|
||||||
|
@ -1054,7 +1055,7 @@ get_parameters()
|
||||||
# the short form only runs if no args output args are used
|
# the short form only runs if no args output args are used
|
||||||
# no need to run through these if there are no args
|
# no need to run through these if there are no args
|
||||||
if [[ -n $1 ]];then
|
if [[ -n $1 ]];then
|
||||||
while getopts Ac:CdDfFGhHiIlNopPrsSt:uv:Vx%@:${update_flags} opt
|
while getopts Ac:CdDfFGhHiIlnNopPrsSt:uv:Vx%@:${update_flags} opt
|
||||||
do
|
do
|
||||||
case $opt in
|
case $opt in
|
||||||
A) B_SHOW_AUDIO='true'
|
A) B_SHOW_AUDIO='true'
|
||||||
|
@ -1105,6 +1106,11 @@ get_parameters()
|
||||||
B_SHOW_PARTITIONS='true'
|
B_SHOW_PARTITIONS='true'
|
||||||
use_short='false'
|
use_short='false'
|
||||||
;;
|
;;
|
||||||
|
n) B_SHOW_ADVANCED_NETWORK='true'
|
||||||
|
B_SHOW_NETWORK='true'
|
||||||
|
B_EXTRA_DATA='true'
|
||||||
|
use_short='false'
|
||||||
|
;;
|
||||||
N) B_SHOW_NETWORK='true'
|
N) B_SHOW_NETWORK='true'
|
||||||
use_short='false'
|
use_short='false'
|
||||||
;;
|
;;
|
||||||
|
@ -1270,7 +1276,8 @@ show_options()
|
||||||
print_screen_output " Not shown with -F for user security reasons, you shouldn't paste your local/wan IP."
|
print_screen_output " Not shown with -F for user security reasons, you shouldn't paste your local/wan IP."
|
||||||
print_screen_output "-I Show Information: processes, uptime, memory, irc client, inxi version."
|
print_screen_output "-I Show Information: processes, uptime, memory, irc client, inxi version."
|
||||||
print_screen_output "-l Show partition labels. Default: short partition -P. For full -p output, use: -pl (or -plu)."
|
print_screen_output "-l Show partition labels. Default: short partition -P. For full -p output, use: -pl (or -plu)."
|
||||||
print_screen_output "-N Show Network card information."
|
print_screen_output "-n Show Advanced Network card information. Same as -Nnx. Shows interface, speed, mac id, state, etc."
|
||||||
|
print_screen_output "-N Show Network card information. With -x, shows PCI BusID, Port number."
|
||||||
print_screen_output "-o Show unmounted partition information (includes UUID and LABEL if available)."
|
print_screen_output "-o Show unmounted partition information (includes UUID and LABEL if available)."
|
||||||
print_screen_output " Shows file system type if you have file installed, if you are root OR if you have"
|
print_screen_output " Shows file system type if you have file installed, if you are root OR if you have"
|
||||||
print_screen_output " added to /etc/sudoers (sudo v. 1.7 or newer): <username> ALL = NOPASSWD: /usr/bin/file (sample)"
|
print_screen_output " added to /etc/sudoers (sudo v. 1.7 or newer): <username> ALL = NOPASSWD: /usr/bin/file (sample)"
|
||||||
|
@ -3017,7 +3024,55 @@ get_networking_data()
|
||||||
}
|
}
|
||||||
}') )
|
}') )
|
||||||
IFS="$ORIGINAL_IFS"
|
IFS="$ORIGINAL_IFS"
|
||||||
|
if [[ $B_SHOW_ADVANCED_NETWORK == 'true' ]];then
|
||||||
|
get_network_advanced_data
|
||||||
|
fi
|
||||||
log_function_data "A_NETWORK_DATA: ${A_NETWORK_DATA[@]}"
|
log_function_data "A_NETWORK_DATA: ${A_NETWORK_DATA[@]}"
|
||||||
|
|
||||||
|
eval $LOGFE
|
||||||
|
}
|
||||||
|
|
||||||
|
get_network_advanced_data()
|
||||||
|
{
|
||||||
|
eval $LOGFS
|
||||||
|
local a_network_adv_working='' card_port='' working_path=''
|
||||||
|
local eth_id='' speed='' duplex='' mac_id='' oper_state=''
|
||||||
|
|
||||||
|
for (( i=0; i < ${#A_NETWORK_DATA[@]}; i++ ))
|
||||||
|
do
|
||||||
|
IFS=","
|
||||||
|
a_network_adv_working=( ${A_NETWORK_DATA[i]} )
|
||||||
|
working_path="/sys/bus/pci/devices/0000:${a_network_adv_working[4]}"
|
||||||
|
if [[ -e $working_path/net ]];then
|
||||||
|
card_port=$( ls $working_path/net 2>/dev/null )
|
||||||
|
eth_id=$card_port
|
||||||
|
working_path=$working_path/net/$card_port
|
||||||
|
# 2.6.32 debian lenny kernel shows not: /net/eth0 but /net:eth0
|
||||||
|
else
|
||||||
|
card_port=$( ls $working_path | grep 'net:' )
|
||||||
|
eth_id=$( cut -d ':' -f 2 <<< "$card_port" )
|
||||||
|
working_path=$working_path/$card_port
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n $card_port ]];then
|
||||||
|
if [[ -f $working_path/speed ]];then
|
||||||
|
speed=$( cat $working_path/speed )
|
||||||
|
fi
|
||||||
|
if [[ -f $working_path/duplex ]];then
|
||||||
|
duplex=$( cat $working_path/duplex )
|
||||||
|
fi
|
||||||
|
if [[ -f $working_path/address ]];then
|
||||||
|
mac_id=$( cat $working_path/address )
|
||||||
|
fi
|
||||||
|
if [[ -f $working_path/operstate ]];then
|
||||||
|
oper_state=$( cat $working_path/operstate )
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
A_NETWORK_DATA[i]=${a_network_adv_working[0]}","${a_network_adv_working[1]}","${a_network_adv_working[2]}","${a_network_adv_working[3]}","${a_network_adv_working[4]}","$eth_id","$oper_state","$speed","$duplex","$mac_id
|
||||||
|
IFS="$ORIGINAL_IFS"
|
||||||
|
done
|
||||||
|
|
||||||
eval $LOGFE
|
eval $LOGFE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4809,6 +4864,7 @@ print_networking_data()
|
||||||
network_data="${C1}$card_one${C2} ${a_network_working[0]}$driver_data$port_data$pci_bus_id"
|
network_data="${C1}$card_one${C2} ${a_network_working[0]}$driver_data$port_data$pci_bus_id"
|
||||||
network_data=$( create_print_line "Network:" "$network_data" )
|
network_data=$( create_print_line "Network:" "$network_data" )
|
||||||
print_screen_output "$network_data"
|
print_screen_output "$network_data"
|
||||||
|
print_network_advanced_data "${a_network_working[4]}"
|
||||||
i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1
|
i=0 ## loop starts with 1 by auto-increment so it only shows cards > 1
|
||||||
while [[ -n ${A_NETWORK_DATA[++i]} ]]
|
while [[ -n ${A_NETWORK_DATA[++i]} ]]
|
||||||
do
|
do
|
||||||
|
@ -4837,7 +4893,9 @@ print_networking_data()
|
||||||
fi
|
fi
|
||||||
network_data="${C1}Card-$(( $i + 1 ))${C2} ${a_network_working[0]}$driver_data$port_data$pci_bus_id"
|
network_data="${C1}Card-$(( $i + 1 ))${C2} ${a_network_working[0]}$driver_data$port_data$pci_bus_id"
|
||||||
network_data=$( create_print_line " " "$network_data" )
|
network_data=$( create_print_line " " "$network_data" )
|
||||||
|
|
||||||
print_screen_output "$network_data"
|
print_screen_output "$network_data"
|
||||||
|
print_network_advanced_data "${a_network_working[4]}"
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
if [[ $B_SHOW_IP == 'true' ]];then
|
if [[ $B_SHOW_IP == 'true' ]];then
|
||||||
|
@ -4846,6 +4904,37 @@ print_networking_data()
|
||||||
eval $LOGFE
|
eval $LOGFE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args: $1 - pci bus id
|
||||||
|
print_network_advanced_data()
|
||||||
|
{
|
||||||
|
eval $LOGFS
|
||||||
|
local network_data='' eth_id='N/A' duplex='N/A' mac_id='N/A' speed='N/A' oper_state='N/A'
|
||||||
|
|
||||||
|
if [[ $B_SHOW_ADVANCED_NETWORK == 'true' ]];then
|
||||||
|
if [[ -n ${a_network_working[5]} ]];then
|
||||||
|
eth_id=${a_network_working[5]}
|
||||||
|
fi
|
||||||
|
if [[ -n ${a_network_working[6]} ]];then
|
||||||
|
oper_state=${a_network_working[6]}
|
||||||
|
fi
|
||||||
|
if [[ -n ${a_network_working[7]} ]];then
|
||||||
|
speed="${a_network_working[7]} Mbps"
|
||||||
|
fi
|
||||||
|
if [[ -n ${a_network_working[8]} ]];then
|
||||||
|
duplex=${a_network_working[8]}
|
||||||
|
fi
|
||||||
|
if [[ -n ${a_network_working[9]} ]];then
|
||||||
|
mac_id=${a_network_working[9]}
|
||||||
|
fi
|
||||||
|
network_data="${C1}IF:${C2} $eth_id ${C1}State:${C2} $oper_state ${C1}Speed:${C2} $speed"
|
||||||
|
network_data="$network_data ${C1}Duplex:${C2} $duplex ${C1}Mac:${C2} $mac_id"
|
||||||
|
network_data=$( create_print_line " " "$network_data" )
|
||||||
|
print_screen_output "$network_data"
|
||||||
|
fi
|
||||||
|
|
||||||
|
eval $LOGFE
|
||||||
|
}
|
||||||
|
|
||||||
print_networking_ip_data()
|
print_networking_ip_data()
|
||||||
{
|
{
|
||||||
eval $LOGFS
|
eval $LOGFS
|
||||||
|
@ -4867,12 +4956,12 @@ print_networking_ip_data()
|
||||||
IFS="$ORIGINAL_IFS"
|
IFS="$ORIGINAL_IFS"
|
||||||
if [[ $i -lt 3 ]];then
|
if [[ $i -lt 3 ]];then
|
||||||
if [[ -n ${a_interfaces_working[0]} ]];then
|
if [[ -n ${a_interfaces_working[0]} ]];then
|
||||||
interfaces="$interfaces ${C1}${a_interfaces_working[0]}${C2} ${a_interfaces_working[1]}"
|
interfaces="$interfaces ${a_interfaces_working[0]} ${C1}IP:${C2} ${a_interfaces_working[1]}"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [[ -n ${a_interfaces_working[0]} ]];then
|
if [[ -n ${a_interfaces_working[0]} ]];then
|
||||||
# space on end here for lining up with line starter
|
# space on end here for lining up with line starter
|
||||||
interfaces_2="$interfaces_2${C1}${a_interfaces_working[0]}${C2} ${a_interfaces_working[1]} "
|
interfaces_2="$interfaces_2${a_interfaces_working[0]} ${C1}IP:${C2} ${a_interfaces_working[1]} "
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
((i++))
|
((i++))
|
||||||
|
|
Loading…
Reference in a new issue