[modify] add new functions of find docker pid and print top 20 info of mem & cpu
This commit is contained in:
17
utool/ps_top_20.sh
Normal file
17
utool/ps_top_20.sh
Normal file
@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
# ps -ely | sort -nrk 8 | head -n 20 | awk 'BEGIN{print "UID", "PID", "PPID", "RSS", "CMD"} {print $2, $3, $4, $8/1024"M", $NF}' | column -t
|
||||
fmt="%-9s%-9s%-6s%-6s\033[1;32m%-8s\033[0m%-10s\n"
|
||||
awk -v fmt=$fmt 'BEGIN{printf fmt, "PID","PPID","%CPU","%MEM","RSS","COMM"}' > /tmp/mem.top
|
||||
ps -eo pid,ppid,pcpu,pmem,rss,comm | grep -Ev "grep|ps" | sort -nrk 5 | head -n 20 | awk -v fmt=$fmt '{printf fmt, $1,$2,$3,$4,int($5/1024)"M",$6}' >> /tmp/mem.top
|
||||
|
||||
> /tmp/deli.top
|
||||
for i in `seq 21`; do
|
||||
echo '|' >> /tmp/deli.top
|
||||
done
|
||||
|
||||
fmt="%-9s%-9s\033[1;34m%-6s\033[0m%-6s%-8s%-10s\n"
|
||||
awk -v fmt=$fmt 'BEGIN{printf fmt, "PID","PPID","%CPU","%MEM","RSS","COMM"}' > /tmp/cpu.top
|
||||
ps -eo pid,ppid,pcpu,pmem,rss,comm | sort -nrk 3 | grep -Ev "grep|ps" | head -n 20 | awk -v fmt=$fmt '{printf fmt, $1,$2,$3,$4,int($5/1024)"M",$6}' >> /tmp/cpu.top
|
||||
|
||||
paste /tmp/mem.top /tmp/deli.top /tmp/cpu.top | column -t
|
||||
rm -rf /tmp/{mem.top,cpu.top,deli.top}
|
Reference in New Issue
Block a user