Skip to content

Instantly share code, notes, and snippets.

@si3mshady
Created August 15, 2022 00:08
Show Gist options
  • Save si3mshady/21f1ed9518397fffabbec5480dad54ec to your computer and use it in GitHub Desktop.
Save si3mshady/21f1ed9518397fffabbec5480dad54ec 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