ALT Linux Bugzilla
– Attachment 9992 Details for
Bug 39620
Добавить утилиту для вывода списка и состояния интерфейсов (ethlist ?)
New bug
|
Search
|
[?]
|
Help
Register
|
Log In
[x]
|
Forgot Password
Login:
[x]
|
EN
|
RU
Кандидат в пакет
ethlist (text/plain), 1.88 KB, created by
Sergey Y. Afonin
on 2021-11-29 09:39:16 MSK
(
hide
)
Description:
Кандидат в пакет
Filename:
MIME Type:
Creator:
Sergey Y. Afonin
Created:
2021-11-29 09:39:16 MSK
Size:
1.88 KB
patch
obsolete
>#!/bin/bash > >dirs=(/sys/class/net/*/device) ># 12345678901234567890123 >if [[ ${#dirs} < 24 ]]; then > echo "hardware network devices not found" > exit 1 >fi > >BUS_L=12 >ETH_L=0 # calculated dynamically >LINK_L=0 # calculated dynamically >SPEED_L=0 # calculated dynamically >DUPLEX_L=22 > >OUT= > >for ETH in `ls -d /sys/class/net/*/device | awk -F "/" '{print $5}' | sed "s/\([a-z]*\)\([0-9]\+\)/\1.\2/" | sort -n -t . -k 2.1 | sed "s/\.//"`; do > > if [ -d /sys/class/net/$ETH/device/ieee80211 ]; then # WiFi device > continue > fi > > ETHTOOL=`ethtool $ETH` > ETHTOOL_I=`ethtool -i $ETH` > > if [[ $ETHTOOL =~ ^.*(Speed:[[:space:]][!/a-zA-Z0-9]+).*(Duplex:[[:space:]][!a-zA-Z0-9]+).*(Link[[:space:]]detected:[[:space:]][a-zA-Z]+) ]]; then > SPEED=${BASH_REMATCH[1]} > DUPLEX=${BASH_REMATCH[2]} > LINK=${BASH_REMATCH[3]} > else > echo "error parse output of \"ethtool\" for $ETH" > exit 1 > fi > > if [[ $ETHTOOL_I =~ ^driver:[[:space:]]([a-zA-Z0-9]+).*bus-info:[[:space:]]([.:/a-zA-Z0-9]+).* ]]; then > DRIVER=${BASH_REMATCH[1]} > BUS=${BASH_REMATCH[2]} > else > echo "error parse output of \"ethtool -i\" for $ETH" > exit 1 > fi > > STR="$ETH ($DRIVER)" > if [[ ${#STR} > $ETH_L ]]; then > ETH_L=${#STR} > fi > > if [[ ${#LINK} > $LINK_L ]]; then > LINK_L=${#LINK} > fi > > if [[ ${#SPEED} > $SPEED_L ]]; then > SPEED_L=${#SPEED} > fi > > OUT=${OUT}"$BUS,$ETH ($DRIVER),$LINK,$SPEED,$DUPLEX;" > >done > >if [[ ${#OUT} = 0 ]]; then > echo "ethernet devices not found" > exit 1 >fi > >B_IFS=$IFS >IFS=";" > >for LINE in $OUT; do > if [[ $LINE =~ ([^,]+),([^,]+),([^,]+),([^,]+),([^,]+) ]]; then > printf "%-${BUS_L}s %-${ETH_L}s : %-${LINK_L}s %-${SPEED_L}s %-${DUPLEX_L}s\n" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}" "${BASH_REMATCH[3]}" "${BASH_REMATCH[4]}" "${BASH_REMATCH[5]}" > fi >done > >IFS=$B_IFS > >exit 0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 39620
:
9163
|
9992
|
15025