-
Notifications
You must be signed in to change notification settings - Fork 1
/
server_info.sh
85 lines (74 loc) · 1.47 KB
/
server_info.sh
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
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
ip_regex="([0-9]{1,3}\.){3}[0-9]{1,3}"
TMPDIR=${TMPDIR:-/tmp}
TMPFILE=$TMPDIR/hwinfo.tmp
LSPCI=$TMPDIR/lspci.tmp
add_lspci() {
if [ ! -x /sbin/lspci ]; then
yum -y install pciutils
fi
}
grab_data() {
for interface in /sys/class/net/*/brport/bridge; do
if [ "$interface" = '/sys/class/net/*/brport/bridge' ]; then
break
fi
bridge="$(readlink $interface | cut -d / -f3)"
eth="$(cut -d / -f5 <<< $interface)"
echo ${bridge#br} $eth
done | sort -n | sed 's/^/br/' > $TMPFILE
lspci > $LSPCI
}
if_ip() {
ip -4 a show $1 | egrep -o $ip_regex/[0-9]+
}
bridges() {
echo
echo "# bridges"
echo
for bridge in $(cut -d ' ' -f1 $TMPFILE | uniq); do
echo $bridge "$(if_ip $bridge)"
for interface in $(grep -w $bridge $TMPFILE | cut -d ' ' -f2); do
echo "- $interface $(if_ip $interface)"
done
done
}
devices() {
echo
echo "# devices"
echo
for eth in $(ip link | egrep -o eth[0-9]+ | sort -u); do
for id in $(ethtool -i $eth | grep bus-info | sed 's/.*0000://'); do
rx_buf="$(ethtool -g $eth | tac | grep RX: | egrep -o [0-9]+ | tr '\n' '/'| sed 's|/$||g')"
echo "$eth: $(grep -w $id $LSPCI) rx: $rx_buf"
done
done
}
_uptime() {
echo
echo "# uptime"
echo
uptime
}
cpu() {
echo
echo "# cpu"
echo
egrep '(processor|model name)' /proc/cpuinfo | tail -2
}
interrupts() {
echo
echo "# interrupts"
echo
grep eth /proc/interrupts
}
main() {
add_lspci
grab_data
bridges
devices
_uptime
cpu
interrupts
}
main | sed -e 's/^[^#$]/ &/g'