Last active
September 6, 2023 15:54
-
-
Save AlexisDucastel/fecc55082f42d4c5f61424ecc86bcde6 to your computer and use it in GitHub Desktop.
Docker resource consumption quick evaluation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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