1.根据http://xxxx.com/nginx_status/ 统计 参考:https://www.oschina.net/code/snippet_226718_17879
#/bin/bash 2 3 #nginx_status_url 手动配置项 4 NGINX_STATUS_URL="http://127.0.0.1/nginx_status" 5 6 #10sec 峰值 7 MAX=1; 8 MAILLIST="foyon0806@gmail.com" 9 10 send_warning() 11 { 12 echo $MESSAGE | /bin/mail -s "$TITLE" "$MAILLIST" 13 } 14 15 QPS1=`curl -s ${NGINX_STATUS_URL} | awk '/server accepts handled requests/{getline a;split(a,d);print d[length(d)]}'` 16 17 #10sec 18 sleep 10 19 20 QPS2=`curl -s ${NGINX_STATUS_URL} | awk '/server accepts handled requests/{getline a;split(a,d);print d[length(d)]}'` 21 echo $QPS1 22 echo $QPS2 23 24 QPS=`expr $QPS2 - $QPS1` 25 DATA=`date` 26 if [ $QPS -ge $MAX ];then 27 TITLE="[serious]: ${NGINX_STATUS_URL}" 28 MESSAGE="Time:${DATA},${NGINX_STATUS_URL} qps per 10 sec more than ${MAX}" 29 send_warning 30 fi 31 exit
2. 总共处理了340975次请求
Active connections:Nginx 正处理的活动连接数 。
server accepts handled requests:Nginx启动到现在共处理了 49894 个连接 , 成功创建 49894 次握手。 一般跟第一个一样,差值为请求丢失数, 总共处理了340975次请求
————————————————
原文链接:https://blog.csdn.net/chenggong2dm/article/details/10002805
3. nginx的QPS解决方案
https://cloud.tencent.com/developer/article/1025433
4.我的用nginx的status得到的qps
[root@slave1 monitor]# cat get_qps.sh #/bin/bash # get qps1 qps1=`curl -s http://12.211.117.24/ngx_status |awk 'NR==3 {print}'|awk '{print $3}'` sleep 1 # get qps2 qps2=`curl -s http://12.211.117.24/ngx_status |awk 'NR==3 {print}'|awk '{print $3}'` #get qps1 -qps2 qps_second=`expr $qps2 - $qps1` echo $qps_second [root@slave1 monitor]#