-
Notifications
You must be signed in to change notification settings - Fork 45
/
ethtool-firmware-version
executable file
·32 lines (30 loc) · 1.43 KB
/
ethtool-firmware-version
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
#!/usr/bin/env bash
# description: Show the nodes' NIC firmware version using ethtool
[ -z ${UTILSFILE} ] && source $(echo "$(dirname ${0})/../utils")
if oc auth can-i debug node >/dev/null 2>&1; then
msg "Checking NIC firmware version using ethtool (${BLUE}using oc debug, it can take a while${NOCOLOR})"
# shellcheck disable=SC2016
for node in $(oc get nodes -o go-template='{{range .items}}{{$node := .}}{{range .status.conditions}}{{if eq .type "Ready"}}{{if eq .status "True"}}node/{{$node.metadata.name}}{{"\n"}}{{end}}{{end}}{{end}}{{end}}'); do
# See https://medium.com/@robert.i.sandor/getting-started-with-parallelization-in-bash-e114f4353691
((i = i % PARALLELJOBS))
((i++ == 0)) && wait
(
ocdebugorwait # Pause for no OC debug running
if ! FIRMWAREVERS=$(oc debug --image="${OSETOOLSIMAGE}" "${node}" -- sh -c "for interface in \$(ls -d /sys/class/net/*/device | cut -d/ -f5); do echo -n \"\${interface} => \"; ethtool -i \${interface} | awk '/firmware-version/ { print substr(\$0, index(\$0,\$2)) }';done" 2>/dev/null); then
msg "${ORANGE}Error running oc debug in ${node}${NOCOLOR}"
else
if [ -n "${FIRMWAREVERS}" ]; then
msg "${node}:\n${FIRMWAREVERS}"
else
msg "Couldn't find NIC firmware version in ${node}"
fi
fi
) &
done
wait
exit ${OCINFO}
else
msg "Couldn't debug nodes, check permissions"
exit ${OCSKIP}
fi
exit ${OCUNKNOWN}