Skip to content

Instantly share code, notes, and snippets.

@gquittet
Created November 14, 2024 12:26
Show Gist options
  • Save gquittet/abfd0f6f6d852e70b7ef5b89fa0da2d3 to your computer and use it in GitHub Desktop.
Save gquittet/abfd0f6f6d852e70b7ef5b89fa0da2d3 to your computer and use it in GitHub Desktop.
Small one-liner to see full network usage of running/all containers
printf "
\e[1mDocker Network Usage\e[0m
\e[3mRunning containers (I/O):\e[0m $(docker stats --format "table {{.NetIO}}" --no-stream | tail -n +2 | sed "s/kB/KB/g" | sed "s/B//g" | cut -d '/' -f1 | numfmt --from=iec | awk '{ sum += $1; } END { print sum; }' | numfmt --to=iec) / $(docker stats --format "table {{.NetIO}}" --no-stream | tail -n +2 | sed "s/kB/KB/g" | sed "s/B//g" | cut -d '/' -f2 | numfmt --from=iec | awk '{ sum += $1; } END { print sum; }' | numfmt --to=iec)
\e[3mAll containers (I/O):\e[0m $(docker stats --all --format "table {{.NetIO}}" --no-stream | tail -n +2 | sed "s/kB/KB/g" | sed "s/B//g" | cut -d '/' -f1 | numfmt --from=iec | awk '{ sum += $1; } END { print sum; }' | numfmt --to=iec) / $(docker stats --all --format "table {{.NetIO}}" --no-stream | tail -n +2 | sed "s/kB/KB/g" | sed "s/B//g" | cut -d '/' -f2 | numfmt --from=iec | awk '{ sum += $1; } END { print sum; }' | numfmt --to=iec)
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment