-
Notifications
You must be signed in to change notification settings - Fork 2
/
eiall
executable file
·72 lines (62 loc) · 2.43 KB
/
eiall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
source /work/tools/scripts/env.sh
#echo -e $GREEN in eiall $NC
for filename in /sys/class/net/*; do
NETDEV=`basename $filename`
if [ "$NETDEV" != "lo" ] && [ "$NETDEV" != "wlan0" ] ; then
echo -n -e $GREEN $NETDEV " "$NC
BUS=`ethtool -i $NETDEV | grep bus | cut -d' ' -f2`
#DRIVER=`ethtool -i $NETDEV | grep driver`
DRIVER=`ethtool -i $NETDEV | grep driver | cut -d':' -f2`
# echo -n $BUS $DRIVER
if [ "$BUS" == "N/A" ] || [ "$BUS" == "tap" ]; then
echo -n " "
else
# echo -n $BUS " "
echo -n $BUS " "
fi
# printf "%8s" $DRIVER
printf "%8s" $DRIVER
#LINK=`ethtool $NETDEV | tail -n 1 | cut -d' ' -f3`
LINK=`ifconfig 2> /dev/null $NETDEV | head -1 | grep UP`
if [ $? -eq 0 ]; then
printf ' \e[1;32m%-4s\e[m' "UP "
# RUNNING=`ifconfig 2> /dev/null $NETDEV | head -1 | grep RUNNING`
# if [ $? -eq 0 ]; then
# printf ' \e[1;32m%-6s\e[m' "RUNNING "
# else
# printf ' \e[1;32m%-6s\e[m' " "
# fi
else
#printf ' \e[1;31m%-6s\e[m' "DOWN"
# printf ' \e[1;31m%-6s\e[m' "DOWN "
printf ' \e[1;31m%-6s\e[m' "DOWN"
fi
VENDORID=''
DEVICEID=''
# [ -e /sys/class/net/$NETDEV/device/device ] && DEVICEID=`cat /sys/class/net/$NETDEV/device/device`
# [ -e /sys/class/net/$NETDEV/device/vendor ] && VENDORID=`cat /sys/class/net/$NETDEV/device/vendor`
[ -e /sys/class/net/$NETDEV/device/device ] && DEVICEID=`sed 's/^0x//' /sys/class/net/$NETDEV/device/device`
[ -e /sys/class/net/$NETDEV/device/vendor ] && VENDORID=`sed 's/^0x//' /sys/class/net/$NETDEV/device/vendor`
[ ! -z $VENDORID ] && echo -n $VENDORID:$DEVICEID
IPADDR=""
if [ "$NETDEV" != "ib0" ] ; then
IPADDR=`ifconfig 2> /dev/null $NETDEV | grep inet | grep -v inet6 | cut -d ' ' -f10`
fi
[ ! -z $IPADDR ] && echo -e $YEL $IPADDR $NC
LINK=`ifconfig 2> /dev/null $NETDEV | head -1 | grep UP`
if [ $? -eq 0 ]; then
# printf ' \e[1;32m%-4s\e[m' "UP"
RUNNING=`ifconfig 2> /dev/null $NETDEV | head -1 | grep RUNNING`
if [ $? -eq 0 ]; then
printf ' \e[1;32m%-6s\e[m' "RUNNING "
else
printf ' \e[1;32m%-6s\e[m' " "
fi
# else
#printf ' \e[1;31m%-6s\e[m' "DOWN"
#printf ' \e[1;31m%-6s\e[m' "DOWN "
fi
echo
fi
done