参考
数据分析
223.104.7.59 - - [05/Dec/2018:00:00:01 +0000] "GET /topics/17112 HTTP/2.0" 200 9874 "https://www.googleapis.com/auth/chrome-content-suggestions" "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/70.0.3538.75 Mobile/15E148 Safari/605.1" 0.040 0.040 .
123.125.71.60 - - [05/Dec/2018:00:00:02 +0000] "GET /yuanyibo/topics?locale=en HTTP/1.1" 200 12164 "-" "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)" 0.032 0.032 .
141.8.142.131 - - [05/Dec/2018:00:00:02 +0000] "GET /topics?page=63 HTTP/1.1" 200 16739 "-" "Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)" 0.120 0.120 .
139.180.131.123 - - [05/Dec/2018:00:00:01 +0000] "GET /cable HTTP/1.1" 101 15073 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" 592.015 592.015 .
40.77.167.60 - - [05/Dec/2018:00:00:03 +0000] "GET /hehe123 HTTP/1.1" 200 3494 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" 0.033 0.033 .
204.141.42.226 - - [05/Dec/2018:00:00:04 +0000] "GET / HTTP/1.1" 301 5 "-" "Site24x7" 0.002 0.002 .
40.77.167.60 - - [05/Dec/2018:00:00:04 +0000] "GET /uploads/user/avatar/11094.jpg!xs HTTP/1.1" 200 1499 "-" "Mozilla/5.0 (compatible; bingbot/2.0; +http://www.bing.com/bingbot.htm)" 0.011 0.011 .
awk '{print $1}' /tmp/nginx.log | sort | uniq -c | sort -nr | head -20 | gnuplot -e "set term dumb; plot '<cat' using 1:(column(0)):ytic(2) with lines; "
111.202.100.96 ++-*------+--------+---------+---------+--------+--------++
125.46.24.19 ++ * + '<cat' using 1:(column(0)):ytic(2) ******++
123.127.112.18 ++ * ++
61.216.142.121 ++ * ++
101.89.64.230 ++ * ++
101.89.64.238 ++ * ++
121.8.148.106 ++ * ++
66.249.71.13 ++ ** ++
157.55.39.240 ++ ** ++
223.104.212.120 ++ * ++
139.180.132.174 ++ * ++
141.8.142.131 ++ * ++
40.77.167.1 ++ * ++
40.77.167.60 ++ * ++
40.77.167.22 ++ ** ++
115.236.50.18 ++ ** ++
144.76.81.72 ++ **** ++
127.0.0.1 ++ ****** ++
136.243.151.90 ++ + + ***************** + ++
216.244.66.241 ++--------+--------+---------+---------+-***************-++
0 50 100 150 200 250 300
Linux 服务器
#ps的cpu统计不准
ps -o %cpu,%mem,pid,ppid 10125
#top命令比较准确
top -p 5838 -d 1 -b -n 20 > /tmp/top.txt
#绘图分析
grep -A1 "%CPU" /tmp/top.txt | grep -v "CPU" | grep -v "\-\-" | awk '{print $9,$10}' | gnuplot -e 'set term dumb;plot "<cat" using 1 with lines'
2 ++-----+------+--*---+------+------+-----+------+------+------+-----++
+ + + * + + + + "<cat" using 1 ****** +
| * |
| ** |
| * * |
1.5 ++ * * ++
| * * |
| * * |
| * * |
1 ++ * * * * * ++
| * * * * * |
| * * * * * * * * |
| * * * * * * * * |
| * * * * * * * * |
0.5 ++ * * * * * * * * ++
| * * * * * * * * |
| * * * * * * * * |
| * * * * * * * * |
+ + * * + * + * + * + * + * + +
0 ***************------***********---+--*--+---********--+---********-++
0 2 4 6 8 10 12 14 16 18 20
通用的加压
for i in {1..10};do echo $i; ((while true;do curl http://127.0.0.1:8080/seveniruby1 ;done) & ) ; sleep 10; done;
Android 系统
- top
- ps
- dumpsys -l
- android studio
自动化测试
adb shell "uiautomator dump && cat /sdcard/window_dump.xml" | grep -oE '<node.*? />' | grep 交易 | sed 's#.*\[\([0-9]*\),\([0-9]*\)\]\[\([0-9]*\),\([0-9]*\)\].*#\1 \2 \3 \4#' | awk '{print ($1+$3)/2,($2+$4)/2}'
adb shell "uiautomator dump && cat /sdcard/window_dump.xml" | grep --line-buffered -oE '<node.*?>' | grep --line-buffered com.xueqiu.android:id/text |
while read line;
do
xy=$(echo "$line" | sed 's#.*\[\([0-9]*\),\([0-9]*\)\]\[\([0-9]*\),\([0-9]*\)\].*#\1 \2 \3 \4#' | awk '{print ($1+$3)/2,($2+$4)/2}') ;
echo $xy;
done
#挨个点击雪球的菜单栏
adb shell "uiautomator dump && cat /sdcard/window_dump.xml" | grep --line-buffered -oE '<node.*?>' | grep --line-buffered com.xueqiu.android:id/text | while read line; do xy=$(echo "$line" | sed 's#.*\[\([0-9]*\),\([0-9]*\)\]\[\([0-9]*\),\([0-9]*\)\].*#\1 \2 \3 \4#' | awk '{print ($1+$3)/2,($2+$4)/2}') ; echo $xy; done | xargs -I {} bash -c "sleep 2;adb shell input tap {} "