|
Bogdan Timofte
authored
3 months ago
|
1
|
#!/usr/bin/env bash
|
|
|
2
|
# check_mcluster_network.sh — Minimal cluster network health check (pretty table)
|
|
|
3
|
|
|
|
4
|
set -e
|
|
|
5
|
|
|
|
6
|
NODES=(baobab ebony tapia autonas1 autonas2)
|
|
|
7
|
CLUSTER_IPS=(192.168.10.91 192.168.10.92 192.168.10.93 192.168.10.95 192.168.10.96)
|
|
|
8
|
MGMT_IPS=(192.168.2.91 192.168.2.92 192.168.2.93 192.168.2.95 192.168.2.96)
|
|
|
9
|
SSH_OPTS="-o BatchMode=yes -o ConnectTimeout=5 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o LogLevel=ERROR"
|
|
|
10
|
|
|
|
11
|
# Thunderbridge/thunderbolt status (unchanged)
|
|
|
12
|
for i in "${!NODES[@]}"; do
|
|
|
13
|
node="${NODES[$i]}"
|
|
|
14
|
mgmt_ip="${MGMT_IPS[$i]}"
|
|
|
15
|
if [[ "$node" == autonas* ]]; then
|
|
|
16
|
continue
|
|
|
17
|
fi
|
|
|
18
|
mtu=$(ssh $SSH_OPTS root@$mgmt_ip "ip link show thunderbridge 2>/dev/null | grep mtu | awk '{print \$5}'" || echo "fail")
|
|
|
19
|
ports=$(ssh $SSH_OPTS root@$mgmt_ip "bridge link | grep master.*thunderbridge | awk '{print \$2}'" | xargs)
|
|
|
20
|
echo "$node: thunderbridge mtu=$mtu ports=$ports"
|
|
|
21
|
ssh $SSH_OPTS root@$mgmt_ip "ip -o link show | grep 'thunderbolt'" | while read -r line; do
|
|
|
22
|
iface=$(echo "$line" | awk '{print $2}')
|
|
|
23
|
mtu=$(echo "$line" | awk '{print $5}')
|
|
|
24
|
up=$(echo "$line" | grep -q 'UP' && echo "up" || echo "down")
|
|
|
25
|
forwarding=$(ssh $SSH_OPTS root@$mgmt_ip "bridge link show dev $iface 2>/dev/null" | grep -q 'state forwarding' && echo "forwarding" || echo "not-forwarding")
|
|
|
26
|
echo " $iface mtu=$mtu $up $forwarding"
|
|
|
27
|
done
|
|
|
28
|
done
|
|
|
29
|
|
|
|
30
|
echo
|
|
|
31
|
# Table header
|
|
|
32
|
printf "%-10s |" "Node"
|
|
|
33
|
for node in "${NODES[@]}"; do
|
|
|
34
|
printf " %10s |" "$node"
|
|
|
35
|
done
|
|
|
36
|
echo
|
|
|
37
|
# localhost row
|
|
|
38
|
printf "%-10s |" "localhost"
|
|
|
39
|
for j in "${!NODES[@]}"; do
|
|
|
40
|
dst_cluster="${CLUSTER_IPS[$j]}"
|
|
|
41
|
if ping -c 1 -W 1 $dst_cluster >/dev/null 2>&1; then
|
|
|
42
|
printf " %10s |" "OK"
|
|
|
43
|
else
|
|
|
44
|
printf " %10s |" "FAILED"
|
|
|
45
|
fi
|
|
|
46
|
done
|
|
|
47
|
echo
|
|
|
48
|
# baobab row
|
|
|
49
|
printf "%-10s |" "baobab"
|
|
|
50
|
baobab_mgmt="${MGMT_IPS[0]}"
|
|
|
51
|
for j in "${!NODES[@]}"; do
|
|
|
52
|
dst_cluster="${CLUSTER_IPS[$j]}"
|
|
|
53
|
if ssh $SSH_OPTS root@$baobab_mgmt "ping -c 1 -W 1 $dst_cluster >/dev/null 2>&1"; then
|
|
|
54
|
printf " %10s |" "OK"
|
|
|
55
|
else
|
|
|
56
|
printf " %10s |" "FAILED"
|
|
|
57
|
fi
|
|
|
58
|
done
|
|
|
59
|
echo
|