forked from RHsyseng/openshift-checks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
restarts
12 lines (11 loc) · 640 Bytes
/
restarts
1
2
3
4
5
6
7
8
9
10
11
12
#!/usr/bin/env bash
if oc auth can-i get pods -A > /dev/null 2>&1; then
restarts=$(oc get pods -o json -A| jq -r ".items[] | { name: .metadata.name, project: .metadata.namespace, restarts: .status.containerStatuses[].restartCount } | select(.restarts > $RESTART_THRESHOLD)" 2>/dev/null)
if [[ -n $restarts ]]; then
RESTARTS=$(echo "${restarts}" | jq -r '. | "\(.project)\t\(.name)\t\(.restarts)"' | column -t -N "NAMESPACE,NAME,RESTARTS")
msg "Pods that have a high restart count (> $RESTART_THRESHOLD):\n${RED}${RESTARTS}${NOCOLOR}"
errors=$(("${errors}"+1))
fi
else
msg "Couldn't get all pods, check permissions"
fi