1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| $ cat grep_pid.sh
srvdir="/root/netty_srv_dir/"
grep -a "$1 root" $srvdir$1.log | sort -k9 -n | head -n1 | awk '{printf "\nCPU min:%4s\t", $9}' grep -a "$1 root" $srvdir$1.log | awk '{sum+=$9;n++}END{printf "avg: %4s\t", sum /n }' grep -a "$1 root" $srvdir$1.log | sort -k9 -n | tail -n1 | awk '{printf " max:%4s\n", $9}'
grep -a "$1 root" $srvdir$1.log | sort -k10 -n | tail -n1 | awk '{printf "MEM: %4s\n",$10}' cat $srvdir$1.log > $1bak.log echo "" > $srvdir$1.log
cat /proc/net/sockstat | grep "TCP" | awk '{print $1,$9}' awk 'BEGIN{print "\nBytesOut\t\tByteIn\t\tPacketsOut\tPacketsIn"}'
grep "total" $srvdir$1.net | sort -t ";" -n -k 3 | tail -n1 | awk -F ";" '{if (NF==16){if($3>1000){printf "%sKB/s\t",$3/1000}else{printf "%sb/s\t\t",$3}}}' grep "total" $srvdir$1.net | sort -t ";" -n -k 4 | tail -n1 | awk -F ";" '{if (NF==16){if($4>1000){printf "%sKB/s\t",$4/1000}else{printf "%sb/s\t\t",$4}}}' grep "total" $srvdir$1.net | sort -t ";" -n -k 6 | tail -n1 | awk -F ";" '{if (NF==16){if($6>1000){printf "%sKB/s\t",$6/1000}else{printf "%sb/s\t\t",$6}}}' grep "total" $srvdir$1.net | sort -t ";" -n -k 7 | tail -n1 | awk -F ";" '{if (NF==16){if($7>1000){printf "%sKB/s\n",$7/1000}else{printf "%sb/s\n",$7}}}' echo "" > $srvdir$1.net
|