forked from RHsyseng/openshift-checks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchronyc
19 lines (18 loc) · 923 Bytes
/
chronyc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/env bash
if oc auth can-i debug node > /dev/null 2>&1; then
msg "Collecting NTP data... (${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
# shellcheck disable=2016
if ! SOURCES=$(oc debug --image="${OCDEBUGIMAGE}" "${node}" -- chroot /host sh -c 'chronyc activity' 2> /dev/null | awk '/sources online/ { print $1 }'); then
msg "${ORANGE}Error running oc debug in ${node}${NOCOLOR}"
else
if [ -n "${SOURCES}" ] && [ "${SOURCES}" -lt 1 ]; then
msg "${RED}Clock doesn't seem to be synced in ${node}${NOCOLOR}"
errors=$(("${errors}"+1))
fi
fi
done
else
msg "Couldn't debug nodes, check permissions"
fi