[modify] add new functions of find docker pid and print top 20 info of mem & cpu

This commit is contained in:
2023-11-30 08:32:14 +08:00
parent ed631e97c2
commit 09f73bb770
3 changed files with 53 additions and 2 deletions

18
utool/pid_in_docker.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
psid=$1
ids=$(docker inspect -f "{{.Id}}" $(docker ps -q))
for did in $ids; do
docker top $did | awk '{print $2, $3}' | grep -wq $psid
if [[ $? -eq 0 ]]; then
echo "Docker ID : $did"
name=$(docker inspect -f '{{.Name}}' $did | tr -d "/")
echo "Docker Name: $name"
exit 0
fi
done
echo "Not a docker (sub)process..."