Skip to content

Instantly share code, notes, and snippets.

@efossas
Created July 5, 2022 04:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save efossas/2bdbb74d07edbbec57939a6f1e61b3a2 to your computer and use it in GitHub Desktop.
Save efossas/2bdbb74d07edbbec57939a6f1e61b3a2 to your computer and use it in GitHub Desktop.
Sort Kubernetes Pod CPU & Memory Usage
# system [cpu|mem]
system() {
if [[ "$1" == "cpu" ]]; then
kubectl top pod --all-namespaces | tail -n +2 | sort --reverse --key 3 --numeric;
elif [[ "$1" == "mem" ]]; then
kubectl top pod --all-namespaces | tail -n +2 | sort --reverse --key 4 --numeric;
else
echo "unknown resource type";
fi;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment