[modify] add new functions of find docker pid and print top 20 info of mem & cpu
This commit is contained in:
18
utool/pid_in_docker.sh
Normal file
18
utool/pid_in_docker.sh
Normal 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..."
|
||||
|
Reference in New Issue
Block a user