#计算qps:
grep -rn ’10/Oct/2017′ ~/logs/nginx/api.access.log.20171011 |awk ‘{ t=substr($4, 2); qps[t]++; }END{ for (q in qps) { print q” “qps[q] } }’ |sort -k2 -n -r |head
#计算时间段内 time ip uri qps
sed -n ‘/01\/Nov\/2017:12:0[0-9]/,/01\/Nov\/2017:12:0[0-9]/p’ ~/logs/nginx/api.access.log |awk ‘{ t=substr($4, 2); split($7, uris, “?”); key=t” “$1″ “uris[1]; qps[key]++; }END{ for ( key in qps ){ print key” “qps[key] } }’ |sort -k4 -n -r |head -n30
#查看报5xx错误的uri频率
awk ‘{ if( $(NF-2) >= 500 ){ split($7, uri, “?”); print uri[1]; } }’ ~/logs/nginx/api.access.log |sort -r |uniq -c
#查询占用内存主要进程
ps aux|head -1; ps aux | sort -k4nr | head -30
详情看下
http://www.ltwen.com/2017/11/01/%E6%9F%A5%E8%AF%A2%E5%8D%A0%E7%94%A8%E5%86%85%E5%AD%98%E4%B8%BB%E8%A6%81%E8%BF%9B%E7%A8%8B/