最近需要業務需要上線,上線前,需要測試post接口數據:爲了測試的效果選擇了不同區域的四個IDC機房做壓測,根據測試結果文件,分析測試結果。
#!/bin/bash ################################################################ # description: user please is a ab test web server # name: web-server # test web: test ab #web test1 result /home/www/post.josn # USER YYYY-MM-DD - ACTION # bruce fu 20017-08-20 - Created # mail [email protected] ############################################################### [ -f /etc/init.d/functions ] && . /etc/init.d/functions ###systemctl PATH post file# post存放post文件目錄######## post_dir="/home/http/*" #please uesr input url read -p "input a True url -- Example: http://www.xxx.xxx :" url_www echo "$url_www" |grep -i '[a-z.]'|grep '\.' if [ $? -eq 1 ];then echo "please input Correct url Example:http://xxx.xxx.xxx" exit 1 else echo " URL Ture start ab web server test" fi function getdir(){ for element in `ls $post_dir` do dir_or_file="$element" /usr/bin/ab -n 1000 -c 1000 -p $dir_or_file -T application/x-www-form-urlencoded $url_www >>/home/www/post1.josn done } while : #死循環,循環兩小時後,退出 do getdir >> /home/www/post.josn 2>&1 sleep 2h exit 0 done