Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 261 lines (231 sloc) 6.738 kb
c8b5ae0c » nniclausse
2006-02-24 use env
1 #!/usr/bin/env bash
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
2
ea000685 » nniclausse
2005-08-16 use bash; solaris does not like 'hostname -s' (jasonwtucker@gmail.com)
3 UNAME=`uname`
4 case $UNAME in
3027f827 » nniclausse
2005-08-16 argh
5 "Linux") HOST=`hostname -s`;;
6 "SunOS") HOST=`hostname`;;
7 *) HOST=`hostname -s`;;
ea000685 » nniclausse
2005-08-16 use bash; solaris does not like 'hostname -s' (jasonwtucker@gmail.com)
8 esac
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
9
13dfdfdc » nniclausse
2005-04-29 update configure & Makefile
10 INSTALL_DIR=@prefix@/lib/erlang/
11 ERL=@ERL@
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
12 MAIN_DIR=$HOME/.tsung
76b47d66 » nniclausse
2004-02-13 save session in main directory instead of log
13 LOG_DIR=$MAIN_DIR/log
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
14 LOG_OPT="log_file \"$LOG_DIR/tsung.log\""
13dfdfdc » nniclausse
2005-04-29 update configure & Makefile
15 VERSION=@PACKAGE_VERSION@
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
16 NAMETYPE="-sname"
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
17
18 LISTEN_PORT=8090
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
19 USE_PARENT_PROXY=false
eff2fce8 » nniclausse
2006-06-13 listening port and dest IP (for pgsql recorder) can be set at runtime…
20 PGSQL_SERVER_IP=127.0.0.1
af90734f » nniclausse
2006-08-08 pgsql recorder: server port can be set with -P (listening port option…
21 PGSQL_SERVER_PORT=5432
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
22 NAME=tsung
23 CONTROLLER=tsung_controller
24 RECORDER=tsung_recorder
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
25
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
26 TSUNGPATH=$INSTALL_DIR/lib/tsung-$VERSION/ebin
27 CONTROLLERPATH=$INSTALL_DIR/lib/tsung_controller-$VERSION/ebin
28 RECORDERPATH=$INSTALL_DIR/lib/tsung_recorder-$VERSION/ebin
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
29
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
30 CONF_OPT_FILE="$HOME/.tsung/tsung.xml"
31 BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_controller-$VERSION/priv/tsung_controller -boot_var TSUNGPATH $INSTALL_DIR "
32 REC_BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_recorder-$VERSION/priv/tsung_recorder -boot_var TSUNGPATH $INSTALL_DIR "
a68c3e67 » nniclausse
2006-02-21 initial debug level also for controller
33 DEBUG_LEVEL=5
ad4f1ed1 » nniclausse
2005-11-12 refactoring of recorder: add plugin architecture for other protocols …
34 RECORDER_PLUGIN="http"
95fb1730 » nniclausse
2004-12-10 add -r option to set the command for starting nodes on remote host (s…
35 ERL_RSH=" -rsh ssh "
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
36 ERL_OPTS=" -smp auto +P 250000 +A 16 +K true @ERL_OPTS@ "
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
37 COOKIE='tsung'
12f1e4d2 » nniclausse
2006-05-03 fix tr args for solaris
38 ERTS_RUN=`$ERL -version 2>&1 | tr -cd 0123456789.`
39 ERTS_BOOT=`grep erts $TSUNGPATH/../priv/tsung.rel | tr -cd 0123456789.`
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
40
41 stop() {
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
42 $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE killer -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller stop_all $HOST -s init stop
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
43 }
44
45 stop_recorder() {
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
46 $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE killer -setcookie $COOKIE -pa $TSUNGPATH -pa $RECORDERPATH -s tsung_recorder stop_all $HOST -s init stop
33626a66 » nniclausse
2008-01-16 ability to record a string with 'record_tag' (TSUN-52)
47 RET=$?
48 if [ $RET == 1 ]; then
49 echo "FAILED"
50 else
51 echo "[OK]"
52 rm $PIDFILE
53 fi
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
54 }
55
c65d43c4 » nniclausse
2005-12-05 fix output msg; fix usage.
56 recorder_status() {
57 PIDFILE="/tmp/tsung_recorder.pid"
58 if [ -f $PIDFILE ]; then
59 echo "Tsung recorder started [OK]"
60 else
61 echo "Tsung recorder not started "
62 fi
63 }
64
0964e946 » nniclausse
2005-11-04 detect version of erlang in boot script and rebuild them if needed
65 checkversion() {
0992b822 » nniclausse
2005-11-13 check if recorder is already running
66 if [ $ERTS_RUN != $ERTS_BOOT ]
0964e946 » nniclausse
2005-11-04 detect version of erlang in boot script and rebuild them if needed
67 then
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
68 echo "Erlang version has changed ! [$ERTS_BOOT] != [$ERTS_RUN]"
69 echo "Must create new boot files (you may have to run this one time as root ! )"
70 makebootfiles
0992b822 » nniclausse
2005-11-13 check if recorder is already running
71 fi
0964e946 » nniclausse
2005-11-04 detect version of erlang in boot script and rebuild them if needed
72 }
73
74 makebootfiles() {
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
75 cd $TSUNGPATH/..
76 echo "creating boot file for tsung application"
77 $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null
0964e946 » nniclausse
2005-11-04 detect version of erlang in boot script and rebuild them if needed
78 cd $CONTROLLERPATH/..
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
79 echo "creating boot file for tsung_controller application"
80 $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null
81 echo "creating boot file for tsung_recorder application"
0964e946 » nniclausse
2005-11-04 detect version of erlang in boot script and rebuild them if needed
82 cd $RECORDERPATH/..
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
83 $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null
0964e946 » nniclausse
2005-11-04 detect version of erlang in boot script and rebuild them if needed
84 }
85
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
86 start() {
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
87 echo "Starting Tsung"
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
88 $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE $CONTROLLER -setcookie $COOKIE $BOOT_OPT \
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
89 -pa $TSUNGPATH -pa $CONTROLLERPATH \
a68c3e67 » nniclausse
2006-02-21 initial debug level also for controller
90 -tsung_controller debug_level $DEBUG_LEVEL \
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
91 -tsung_controller config_file \"$CONF_OPT_FILE\" -tsung_controller $LOG_OPT
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
92 }
93
94 recorder() {
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
95 echo "Starting Tsung recorder on port $LISTEN_PORT"
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
96 $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE $RECORDER -setcookie $COOKIE $REC_BOOT_OPT \
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
97 -pa $TSUNGPATH -pa $RECORDERPATH -pa $CONTROLLERPATH \
a68c3e67 » nniclausse
2006-02-21 initial debug level also for controller
98 -tsung_recorder debug_level $DEBUG_LEVEL \
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
99 -tsung_recorder $LOG_OPT \
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
100 -tsung_recorder parent_proxy $USE_PARENT_PROXY \
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
101 -tsung_recorder plugin ts_proxy_$RECORDER_PLUGIN \
102 -tsung_recorder proxy_log_file \"$MAIN_DIR/tsung_recorder.xml\" \
eff2fce8 » nniclausse
2006-06-13 listening port and dest IP (for pgsql recorder) can be set at runtime…
103 -tsung_recorder pgsql_server \"${PGSQL_SERVER_IP}\" \
af90734f » nniclausse
2006-08-08 pgsql recorder: server port can be set with -P (listening port option…
104 -tsung_recorder pgsql_port ${PGSQL_SERVER_PORT} \
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
105 -tsung_recorder proxy_listen_port $LISTEN_PORT &
106 echo $! > /tmp/tsung_recorder.pid
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
107 }
108
7fbd71d7 » nniclausse
2004-03-31 check if config file exist
109 debug() {
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
110 $ERL $ERL_OPTS $ERL_RSH $NAMETYPE $CONTROLLER -setcookie $COOKIE $BOOT_OPT \
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
111 -pa $TSUNGPATH -pa $CONTROLLERPATH \
112 -tsung_controller config_file \"$CONF_OPT_FILE\" \
113 -tsung_controller $LOG_OPT
7fbd71d7 » nniclausse
2004-03-31 check if config file exist
114 }
115
13dfdfdc » nniclausse
2005-04-29 update configure & Makefile
116 version() {
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
117 echo "Tsung version $VERSION"
13dfdfdc » nniclausse
2005-04-29 update configure & Makefile
118 }
119
7fbd71d7 » nniclausse
2004-03-31 check if config file exist
120 checkconfig() {
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
121 if [ ! -e $CONF_OPT_FILE ]
122 then
123 echo "Config file $CONF_OPT_FILE doesn't exist, aborting !"
124 exit 1
125 fi
7fbd71d7 » nniclausse
2004-03-31 check if config file exist
126 }
127
1ffd1ecc » nniclausse
2004-03-18 add configure scripts to detect erlang installation directory and com…
128 maindir() {
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
129 if [ ! -d $MAIN_DIR ]
130 then
131 echo "Creating local Tsung directory $MAIN_DIR"
132 mkdir $MAIN_DIR
133 fi
1ffd1ecc » nniclausse
2004-03-18 add configure scripts to detect erlang installation directory and com…
134 }
7fbd71d7 » nniclausse
2004-03-31 check if config file exist
135
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
136 logdir() {
137 if [ ! -d $LOG_DIR ]
138 then
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
139 echo "Creating Tsung log directory $LOG_DIR"
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
140 mkdir $LOG_DIR
141 fi
142 }
143
144 status() {
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
145 SNAME=tsung_status_$RANDOM
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
146 $ERL -noshell $NAMETYPE $SNAME -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller status $HOST -s init stop
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
147 }
148
33626a66 » nniclausse
2008-01-16 ability to record a string with 'record_tag' (TSUN-52)
149 record_tag() {
150 shift
151 SNAME=tsung_recordtag
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
152 $ERL -noshell $NAMETYPE $SNAME -setcookie $COOKIE -pa $TSUNGPATH -pa $RECORDERPATH -run ts_proxy_recorder recordtag $HOST "$*" -s init stop
33626a66 » nniclausse
2008-01-16 ability to record a string with 'record_tag' (TSUN-52)
153 }
154
0992b822 » nniclausse
2005-11-13 check if recorder is already running
155 checkrunning_controller() {
156 RES=`status`
c65d43c4 » nniclausse
2005-12-05 fix output msg; fix usage.
157 if [ "$RES" != "Tsung is not started" ]; then
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
158 echo "Tsung is already running, exit."
0992b822 » nniclausse
2005-11-13 check if recorder is already running
159 exit 1
160 fi
161 }
162
163 checkrunning(){
164 if [ -f $PIDFILE ]; then
165 CURPID=`cat $PIDFILE`
166 if kill -0 $CURPID 2> /dev/null ; then
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
167 echo "Can't start: Tsung recorder already running !"
0992b822 » nniclausse
2005-11-13 check if recorder is already running
168 exit 1
169 fi
170 fi
171 }
172
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
173 usage() {
c65d43c4 » nniclausse
2005-12-05 fix output msg; fix usage.
174 prog=`basename $0`
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
175 echo "$prog <options> start|stop|restart|debug|status|recorder|stop_recorder|version"
c65d43c4 » nniclausse
2005-12-05 fix output msg; fix usage.
176 exit
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
177 }
178
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
179 while getopts ":f:p:l:d:r:i:P:L:I:u:F" Option
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
180 do
181 case $Option in
7fbd71d7 » nniclausse
2004-03-31 check if config file exist
182 f) CONF_OPT_FILE=$OPTARG;;
459db7e9 » nniclausse
2008-03-28 absolute path needed for logfile name (fix TSUN-57)
183 l) # must add absolute path
184 echo "$OPTARG" | grep -q "^/"
185 RES=$?
186 if [ "$RES" == 0 ]; then
187 LOG_OPT="log_file \"$OPTARG\" "
188 else
189 LOG_OPT="log_file \"$PWD/$OPTARG\" "
190 fi
191 ;;
a68c3e67 » nniclausse
2006-02-21 initial debug level also for controller
192 d) DEBUG_LEVEL=$OPTARG;;
95fb1730 » nniclausse
2004-12-10 add -r option to set the command for starting nodes on remote host (s…
193 r) ERL_RSH=" -rsh $OPTARG ";;
ad4f1ed1 » nniclausse
2005-11-12 refactoring of recorder: add plugin architecture for other protocols …
194 p) RECORDER_PLUGIN=$OPTARG;;
af90734f » nniclausse
2006-08-08 pgsql recorder: server port can be set with -P (listening port option…
195 I) PGSQL_SERVER_IP=$OPTARG;;
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
196 u) USE_PARENT_PROXY=true;;
d38c657e » nniclausse
2008-07-15 can use FQDN (-name instead of -sname) with -F flag
197 F) NAMETYPE="-name";;
af90734f » nniclausse
2006-08-08 pgsql recorder: server port can be set with -P (listening port option…
198 P) PGSQL_SERVER_PORT=$OPTARG;;
199 L) LISTEN_PORT=$OPTARG;;
f2c04e92 » nniclausse
2004-02-12 argh, stupid typo
200 *) usage ;;
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
201 esac
3493e621 » nniclausse
2007-06-21 add parent proxy support for http: first step (TSUN-37)
202 done
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
203 shift $(($OPTIND - 1))
204
205 case $1 in
206 start)
0992b822 » nniclausse
2005-11-13 check if recorder is already running
207 checkconfig
208 checkversion
1ffd1ecc » nniclausse
2004-03-18 add configure scripts to detect erlang installation directory and com…
209 maindir
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
210 logdir
211 start
212 ;;
213 recorder)
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
214 PIDFILE="/tmp/tsung_recorder.pid"
0992b822 » nniclausse
2005-11-13 check if recorder is already running
215 checkversion
1ffd1ecc » nniclausse
2004-03-18 add configure scripts to detect erlang installation directory and com…
216 maindir
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
217 logdir
0992b822 » nniclausse
2005-11-13 check if recorder is already running
218 checkrunning
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
219 recorder
220 ;;
221
33626a66 » nniclausse
2008-01-16 ability to record a string with 'record_tag' (TSUN-52)
222 record_tag)
223 record_tag $*
224 ;;
0964e946 » nniclausse
2005-11-04 detect version of erlang in boot script and rebuild them if needed
225 boot)
0992b822 » nniclausse
2005-11-13 check if recorder is already running
226 checkversion
227 ;;
0964e946 » nniclausse
2005-11-04 detect version of erlang in boot script and rebuild them if needed
228
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
229 debug)
0992b822 » nniclausse
2005-11-13 check if recorder is already running
230 checkconfig
231 checkversion
1ffd1ecc » nniclausse
2004-03-18 add configure scripts to detect erlang installation directory and com…
232 maindir
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
233 logdir
234 debug
235 ;;
236
237 stop)
238 stop
239 ;;
240 stop_recorder)
5345a3b5 » nniclausse
2005-11-27 rename idx-tsunami to tsung step 3
241 PIDFILE="/tmp/tsung_recorder.pid"
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
242 stop_recorder
243 ;;
244
245 status)
c65d43c4 » nniclausse
2005-12-05 fix output msg; fix usage.
246 recorder_status
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
247 status
248 ;;
249
250 restart)
251 stop
252 start
253 ;;
13dfdfdc » nniclausse
2005-04-29 update configure & Makefile
254 version)
255 version
256 ;;
748e9e03 » nniclausse
2004-02-11 major source reorganisation to ease debian packaging
257
258 *)
259 usage $0
260 ;;
261 esac
Something went wrong with that request. Please try again.