1、查看~下有没有.tsung目录,没有需要创建 mkdir ~/.tsung 2、cd ~/.tsung 3、创建几个文件(ts.sh、ts.xml、tsung-1.0.dtd) 1)ts.sh
#!/bin/bash
reportPath="./logs"
currentTest=`date +%Y%m%d-%H%M`
reportPaths="$reportPath/$currentTest"
tsung -f ts.xml -l $reportPath start &
wait %1
cd $reportPaths
tsung_stats.pl
python -m SimpleHTTPServer 8080
2)ts.xml
<?xml version="1.0"?>
<!DOCTYPE tsung SYSTEM "/usr/local/share/tsung/tsung-1.0.dtd">
<tsung loglevel="notice" version="1.0">
<!-- Client side setup -->
<clients>
<client host="localhost" use_controller_vm="true"/>
</clients>
<!-- Server side setup -->
<servers>
<server host="www.yh.com" port="443" type="tcp"></server>
</servers>
<!-- to start os monitoring (cpu, network, memory). Use an erlang
agent on the remote machine or SNMP. erlang is the default -->
<monitoring>
<monitor host="myserver" type="snmp"></monitor>
</monitoring>
<load>
<!-- several arrival phases can be set: for each phase, you can set
the mean inter-arrival time between new clients and the phase
duration -->
<arrivalphase phase="1" duration="1" unit="minute">
<users interarrival="2" unit="second"></users>
</arrivalphase>
</load>
<options>
<option type="ts_http" name="user_agent">
<!--<user_agent probability="80">Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Galeon/1.3.21</user_agent>
<user_agent probability="20">Mozilla/5.0 (Windows; U; Windows NT 5.2; fr-FR; rv:1.7.8) Gecko/20050511 Firefox/1.0.4</user_agent>
-->
<user_agent probability="100">Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.67 Safari/537.36></user_agent>
</option>
</options>
<!-- start a session for a http user. the probability is the
frequency of this type os session. The sum of all session's
probabilities must be 100 -->
<sessions>
<session name="http-example" probability="100" type="ts_http">
<request> <http url="/api/pe11406" method="POST" version="1.1" contents="ordersDataType=-1&page=1&perPage=10&uid=952266548232159445&sid=8ba6550932934e1522581f4dcec7038a" content_type="application/x-www-form-urlencoded"></http> </request>
<thinktime value="20" random="true"></thinktime>
</session>
</sessions>
</tsung>
3)tsung-1.0.dtd 默认安装在/usr/local/share/tsung/