Skip to content

Instantly share code, notes, and snippets.

@AlexisDucastel
Last active September 6, 2023 15:54
Show Gist options
  • Save AlexisDucastel/fecc55082f42d4c5f61424ecc86bcde6 to your computer and use it in GitHub Desktop.
Save AlexisDucastel/fecc55082f42d4c5f61424ecc86bcde6 to your computer and use it in GitHub Desktop.
Docker resource consumption quick evaluation
function getdockerstat {
for CTID in $@
do
CTNAME=$(docker inspect $CTID|grep ' "Name"'|head -n 1 |awk '{print $2}'|tr -d '",')
CTCONSO=$(docker stats --no-stream $CTID |tail -n 1|awk '{print $3" "$4}')
echo "=======[ CT $CTID ($CTNAME) ]========"
echo " Conso: $CTCONSO"
docker inspect $CTID \
|grep ' "Source":'\
|awk '{print $2}'\
|tr -d '",' \
|while read MOUNT
do
MOUNTDU=$(du -s $MOUNT|awk '{print $1}')
echo -e " $MOUNTDU\t$MOUNT"
done
done
}
getdockerstat $(docker ps --format 'table {{.ID}} {{.Names}}' |grep -v "cadvisor"|grep -v "nodeexporter"|tail -n +2|awk '{print $1}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment