- #/bin/bash
- #nginx_status_url 手动配置项
- NGINX_STATUS_URL="http://127.0.0.1/nginx_status"
- #10sec 峰值
- MAX=1;
- MAILLIST="foyon0806@gmail.com"
- send_warning()
- {
- echo $MESSAGE | /bin/mail -s "$TITLE" "$MAILLIST"
- }
- QPS1=`curl -s ${NGINX_STATUS_URL} | awk '/server accepts handled requests/{getline a;split(a,d);print d[length(d)]}'`
- #10sec
- sleep 10
- QPS2=`curl -s ${NGINX_STATUS_URL} | awk '/server accepts handled requests/{getline a;split(a,d);print d[length(d)]}'`
- echo $QPS1
- echo $QPS2
- QPS=`expr $QPS2 - $QPS1`
- DATA=`date`
- if [ $QPS -ge $MAX ];then
- TITLE="[serious]: ${NGINX_STATUS_URL}"
- MESSAGE="Time:${DATA},${NGINX_STATUS_URL} qps per 10 sec more than ${MAX}"
- send_warning
- fi
- exit
- #该片段来自于http://www.codesnippet.cn/detail/040620133761.html
来源: http://www.codesnippet.cn/detail/040620133761.html