Skip to content

Instantly share code, notes, and snippets.

@edtshuma
Forked from si3mshady/error_count_kubectl.awk
Created August 17, 2022 09:51
Show Gist options
  • Save edtshuma/58e6af9c669d352b1fb043f0b73f2c84 to your computer and use it in GitHub Desktop.
Save edtshuma/58e6af9c669d352b1fb043f0b73f2c84 to your computer and use it in GitHub Desktop.
AWK practice - filter kubectl output to show counts for running, errorImagePull and imagePullBackup
BEGIN {
imagePullBackOff=0
running=0
errorImagePull=0
}
{
if ( match($3,/ImagePullBackOff/)) { imagePullBackOff++ ; system("echo 1 >> ./imagePullBackOff")}
else if ( match($3,/ErrImagePull/)) {errorImagePull++ ; system("echo 1 >> ./errorImagePull")}
else if ( match($3,/Running/)) {running++ ; system("echo 1 >> ./running") }
}
END {
print "Total running count", running
print "Total errorImagePull count", errorImagePull
print "Total imagePullbackOff count", imagePullBackOff
}
#kubectl get pods | awk -f <filename>.awk
#Elliott Arnold 8-14-22. Working w/ Client
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment