Skip to content

Commit

Permalink
feat(docker_netstat): add docker netstat
Browse files Browse the repository at this point in the history
add docker netstat

Signed-off-by: mritd <[email protected]>
  • Loading branch information
mritd committed Jun 29, 2020
1 parent a3b67e9 commit fb49c5f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions docker_netstat.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env bash

CONTAINER=$1

if [ ! ${CONTAINER} ]; then
echo "CONTAINER is empty!"
exit 1
fi

docker inspect --format '{{.State.Pid}} {{printf "%.13s" .ID}} {{.Name}}' ${CONTAINER} | \
while read CONTAINER_PID CONTAINER_ID CONTAINER_NAME; do
echo ${CONTAINER_ID} ${CONTAINER_NAME} ${CONTAINER_PID}
nsenter -t ${CONTAINER_PID} -n netstat -pan | grep ESTABLISHED
done

0 comments on commit fb49c5f

Please sign in to comment.