清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
1 #/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
~
~