Skip to content

Instantly share code, notes, and snippets.

@pvalena
Created September 12, 2018 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pvalena/3ac18c3bc7ef6d0eeaffedb7e0b7e287 to your computer and use it in GitHub Desktop.
Save pvalena/3ac18c3bc7ef6d0eeaffedb7e0b7e287 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# ./getocstatus.sh [interval]
#
i="${1:-10}"
main () {
{
oc get
echo " * templates"
} 2>&1 | grep '^ *' | tr -s '\t' ' ' | cut -d' ' -f3 | sort -u \
| grep -vE '^(all|podpreset|serviceaccounts|rolebindings|clusterroles|events|persistentvolumes|imagestreamtags|projects|secrets|userserror\:)$' \
| while read n; do
d="$(
{ oc get "$n" ; } 2>&1 \
| grep -v '^No resources found.$' \
| grep -v '^Error from server (Forbidden): ' \
| grep -v '^Error from server (NotFound): ' \
| grep -v "^error: the server doesn't have a resource type " \
| grep -v "^The connection to the server " \
)"
[[ -z "$d" ]] && continue
echo -e "\n >>> $n\n$d"
done
}
P=
while X="`main`"; do
[[ "$P" == "$X" ]] && continue
clear
echo "$X"
P="$X"
sleep $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment