nginx的QPS統計


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]# 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM