本文共 1258 字,大约阅读时间需要 4 分钟。
#!/bin/sh#回显执行的命令和参数set -xcd ../../utils . ./sys_info.shcd -#检查是否是root用户if [ `whoami` != 'root' ] ; then echo "You must be the superuser to run this script" >&2 exit 1fi#distro=`cat /etc/redhat-release | cut -b 1-6`#看起来centos 会通过源码编译httpperfcase $distro in"centos") yum install make -y wget ftp://ftp.hpl.hp.com/pub/httperf/httperf-0.9.0.tar.gz tar -zxvf httperf-0.9.0.tar.gz cd httperf-0.9.0 ./configure --build=arm-linux make make install print_info $? install-package ;; "ubuntu") apt-get install httperf -y print_info $? install-package ;;esac#Test ' httperf server'#执行httperf测试,并加log输出到文件中httperf --server sina.com.cn --num-conn 300 --rate 30 2>&1 | tee httperf.logprint_info $? httper-test$TCID="httperf-test"#在文件中查找关键字符串,后面会根据这个字符串是否为null,来判断是否执行成功str=`grep -Po "total 0" httperf.log`if [ "$str" != "" ] ; then lava-test-case $TCID --result passelse lava-test-case $TCID --result failefi#根据进程名杀掉进程pkill httperf删除logrm httperf.log#删除包case $distro in "centos") yum remove make -y rm -f httperf-0.9.0.tar.gz rm -rf httperf-0.9.0 print_info $? remove-httperf ;; "ubuntu") apt-get remove httperf -y print_info $? remove-httperf ;;esac
转载地址:http://gznmi.baihongyu.com/