Skip to content
Newer
Older
100755 206 lines (185 sloc) 5.59 KB
c8b5ae0 @nniclausse use env
nniclausse authored Feb 24, 2006
1 #!/usr/bin/env bash
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
2
ea00068 @nniclausse use bash; solaris does not like 'hostname -s' (jasonwtucker@gmail.com)
nniclausse authored Aug 16, 2005
3 UNAME=`uname`
4 case $UNAME in
c1163bd @nniclausse add gen_server to choose local ports to bypass the 64K limit.
nniclausse authored Mar 5, 2010
5 "Linux")
6 HOST=`hostname -s 2>/dev/null`
7 RET=$?
8 if [ $RET != 0 ]; then
9 HOST=`hostname`
10 echo "WARN: hostname -s failed, use '$HOST' as hostname" > /dev/stderr
11 fi
12 ;;
3027f82 @nniclausse argh
nniclausse authored Aug 16, 2005
13 "SunOS") HOST=`hostname`;;
14 *) HOST=`hostname -s`;;
ea00068 @nniclausse use bash; solaris does not like 'hostname -s' (jasonwtucker@gmail.com)
nniclausse authored Aug 16, 2005
15 esac
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
16
9bf3b0c @nniclausse fix libdir (can be lib64 on some OS)
nniclausse authored May 18, 2011
17 INSTALL_DIR=@EXPANDED_LIBDIR@/erlang/
13dfdfd @nniclausse update configure & Makefile
nniclausse authored Apr 29, 2005
18 ERL=@ERL@
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
19 MAIN_DIR=$HOME/.tsung
76b47d6 @nniclausse save session in main directory instead of log
nniclausse authored Feb 13, 2004
20 LOG_DIR=$MAIN_DIR/log
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
21 LOG_OPT="log_dir \"$LOG_DIR/\""
22 MON_FILE="mon_file \"tsung.log\""
13dfdfd @nniclausse update configure & Makefile
nniclausse authored Apr 29, 2005
23 VERSION=@PACKAGE_VERSION@
d38c657 @nniclausse can use FQDN (-name instead of -sname) with -F flag
nniclausse authored Jul 15, 2008
24 NAMETYPE="-sname"
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
25
26 LISTEN_PORT=8090
3493e62 @nniclausse add parent proxy support for http: first step (TSUN-37)
nniclausse authored Jun 21, 2007
27 USE_PARENT_PROXY=false
eff2fce @nniclausse listening port and dest IP (for pgsql recorder) can be set at runtime…
nniclausse authored Jun 13, 2006
28 PGSQL_SERVER_IP=127.0.0.1
af90734 @nniclausse pgsql recorder: server port can be set with -P (listening port option…
nniclausse authored Aug 8, 2006
29 PGSQL_SERVER_PORT=5432
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
30 NAME=tsung
31 CONTROLLER=tsung_controller
688f3c9 @nniclausse disable smp by default on client beams (TSUN-97)
nniclausse authored Nov 27, 2008
32 SMP_DISABLE=true
c1163bd @nniclausse add gen_server to choose local ports to bypass the 64K limit.
nniclausse authored Mar 5, 2010
33 WARM_TIME=10
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
34
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
35 TSUNGPATH=$INSTALL_DIR/lib/tsung-$VERSION/ebin
36 CONTROLLERPATH=$INSTALL_DIR/lib/tsung_controller-$VERSION/ebin
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
37
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
38 CONF_OPT_FILE="$HOME/.tsung/tsung.xml"
39 BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_controller-$VERSION/priv/tsung_controller -boot_var TSUNGPATH $INSTALL_DIR "
a68c3e6 @nniclausse initial debug level also for controller
nniclausse authored Feb 21, 2006
40 DEBUG_LEVEL=5
95fb173 @nniclausse add -r option to set the command for starting nodes on remote host (s…
nniclausse authored Dec 10, 2004
41 ERL_RSH=" -rsh ssh "
c1163bd @nniclausse add gen_server to choose local ports to bypass the 64K limit.
nniclausse authored Mar 5, 2010
42 ERL_DIST_PORTS=" -kernel inet_dist_listen_min 64000 -kernel inet_dist_listen_max 65500 "
5c180b2 @nniclausse Merge branch 'localports' into start-sequence
nniclausse authored Aug 6, 2010
43 ERL_OPTS=" $ERL_DIST_PORTS -smp auto +P 250000 +A 16 +K true @ERL_OPTS@ "
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
44 COOKIE='tsung'
12f1e4d @nniclausse fix tr args for solaris
nniclausse authored May 3, 2006
45 ERTS_RUN=`$ERL -version 2>&1 | tr -cd 0123456789.`
4c0948f @nniclausse split tsung command into tsung and tsung-recorder (TSUN-113)
nniclausse authored Mar 5, 2009
46 ERTS_BOOT=`grep erts $TSUNGPATH/../priv/tsung.rel 2> /dev/null| tr -cd 0123456789.`
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
47
48 stop() {
d38c657 @nniclausse can use FQDN (-name instead of -sname) with -F flag
nniclausse authored Jul 15, 2008
49 $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE killer -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller stop_all $HOST -s init stop
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
50 }
51
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored Nov 4, 2005
52 checkversion() {
0992b82 @nniclausse check if recorder is already running
nniclausse authored Nov 13, 2005
53 if [ $ERTS_RUN != $ERTS_BOOT ]
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored Nov 4, 2005
54 then
3493e62 @nniclausse add parent proxy support for http: first step (TSUN-37)
nniclausse authored Jun 21, 2007
55 echo "Erlang version has changed ! [$ERTS_BOOT] != [$ERTS_RUN]"
56 echo "Must create new boot files (you may have to run this one time as root ! )"
57 makebootfiles
0992b82 @nniclausse check if recorder is already running
nniclausse authored Nov 13, 2005
58 fi
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored Nov 4, 2005
59 }
60
61 makebootfiles() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
62 cd $TSUNGPATH/..
63 echo "creating boot file for tsung application"
64 $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored Nov 4, 2005
65 cd $CONTROLLERPATH/..
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
66 echo "creating boot file for tsung_controller application"
67 $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored Nov 4, 2005
68 }
69
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
70 start() {
3493e62 @nniclausse add parent proxy support for http: first step (TSUN-37)
nniclausse authored Jun 21, 2007
71 echo "Starting Tsung"
d38c657 @nniclausse can use FQDN (-name instead of -sname) with -F flag
nniclausse authored Jul 15, 2008
72 $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE $CONTROLLER -setcookie $COOKIE $BOOT_OPT \
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
73 -pa $TSUNGPATH -pa $CONTROLLERPATH \
a27bb83 @nniclausse fix env. name for smp
nniclausse authored Mar 18, 2009
74 -tsung_controller smp_disable $SMP_DISABLE \
a68c3e6 @nniclausse initial debug level also for controller
nniclausse authored Feb 21, 2006
75 -tsung_controller debug_level $DEBUG_LEVEL \
c1163bd @nniclausse add gen_server to choose local ports to bypass the 64K limit.
nniclausse authored Mar 5, 2010
76 -tsung_controller warm_time $WARM_TIME \
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
77 -tsung_controller config_file \"$CONF_OPT_FILE\" -tsung_controller $LOG_OPT -tsung_controller $MON_FILE
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
78 }
79
7fbd71d @nniclausse check if config file exist
nniclausse authored Mar 31, 2004
80 debug() {
d38c657 @nniclausse can use FQDN (-name instead of -sname) with -F flag
nniclausse authored Jul 15, 2008
81 $ERL $ERL_OPTS $ERL_RSH $NAMETYPE $CONTROLLER -setcookie $COOKIE $BOOT_OPT \
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
82 -pa $TSUNGPATH -pa $CONTROLLERPATH \
83 -tsung_controller config_file \"$CONF_OPT_FILE\" \
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
84 -tsung_controller $LOG_OPT -tsung_controller $MON_FILE
7fbd71d @nniclausse check if config file exist
nniclausse authored Mar 31, 2004
85 }
86
13dfdfd @nniclausse update configure & Makefile
nniclausse authored Apr 29, 2005
87 version() {
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
88 echo "Tsung version $VERSION"
4c0948f @nniclausse split tsung command into tsung and tsung-recorder (TSUN-113)
nniclausse authored Mar 5, 2009
89 exit 0
13dfdfd @nniclausse update configure & Makefile
nniclausse authored Apr 29, 2005
90 }
91
7fbd71d @nniclausse check if config file exist
nniclausse authored Mar 31, 2004
92 checkconfig() {
3493e62 @nniclausse add parent proxy support for http: first step (TSUN-37)
nniclausse authored Jun 21, 2007
93 if [ ! -e $CONF_OPT_FILE ]
94 then
95 echo "Config file $CONF_OPT_FILE doesn't exist, aborting !"
96 exit 1
97 fi
7fbd71d @nniclausse check if config file exist
nniclausse authored Mar 31, 2004
98 }
99
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored Mar 18, 2004
100 maindir() {
3493e62 @nniclausse add parent proxy support for http: first step (TSUN-37)
nniclausse authored Jun 21, 2007
101 if [ ! -d $MAIN_DIR ]
102 then
103 echo "Creating local Tsung directory $MAIN_DIR"
104 mkdir $MAIN_DIR
105 fi
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored Mar 18, 2004
106 }
7fbd71d @nniclausse check if config file exist
nniclausse authored Mar 31, 2004
107
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
108 logdir() {
109 if [ ! -d $LOG_DIR ]
110 then
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
111 echo "Creating Tsung log directory $LOG_DIR"
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
112 mkdir $LOG_DIR
113 fi
114 }
115
116 status() {
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
117 SNAME=tsung_status_$RANDOM
d38c657 @nniclausse can use FQDN (-name instead of -sname) with -F flag
nniclausse authored Jul 15, 2008
118 $ERL -noshell $NAMETYPE $SNAME -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller status $HOST -s init stop
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
119 }
120
0992b82 @nniclausse check if recorder is already running
nniclausse authored Nov 13, 2005
121 checkrunning_controller() {
122 RES=`status`
c65d43c @nniclausse fix output msg; fix usage.
nniclausse authored Dec 5, 2005
123 if [ "$RES" != "Tsung is not started" ]; then
5345a3b @nniclausse rename idx-tsunami to tsung step 3
nniclausse authored Nov 27, 2005
124 echo "Tsung is already running, exit."
0992b82 @nniclausse check if recorder is already running
nniclausse authored Nov 13, 2005
125 exit 1
126 fi
127 }
128
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
129 usage() {
c65d43c @nniclausse fix output msg; fix usage.
nniclausse authored Dec 5, 2005
130 prog=`basename $0`
4c0948f @nniclausse split tsung command into tsung and tsung-recorder (TSUN-113)
nniclausse authored Mar 5, 2009
131 echo "Usage: $prog <options> start|stop|debug|status"
132 echo "Options:"
133 echo " -f <file> set configuration file (default is ~/.tsung/tsung.xml)"
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
134 echo " -l <logdir> set log directory (default is ~/.tsung/log/YYYYMMDD-HHMM/)"
c1163bd @nniclausse add gen_server to choose local ports to bypass the 64K limit.
nniclausse authored Mar 5, 2010
135 echo " -i <id> set controller id (default is empty)"
4c0948f @nniclausse split tsung command into tsung and tsung-recorder (TSUN-113)
nniclausse authored Mar 5, 2009
136 echo " -r <command> set remote connector (default is ssh)"
239c2c3 @nniclausse add option to enable smp on client beams (controller is already smp)
nniclausse authored Mar 5, 2010
137 echo " -s enable erlang smp on client nodes"
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
138 echo " -m <file> write monitoring output on this file (default is tsung.log)"
139 echo " (use - for standard output)"
e60ee84 @nniclausse add doc for -F option
nniclausse authored Apr 20, 2009
140 echo " -F use long names (FQDN) for erlang nodes"
c1163bd @nniclausse add gen_server to choose local ports to bypass the 64K limit.
nniclausse authored Mar 5, 2010
141 echo " -w warmup delay (default is 10 sec)"
4c0948f @nniclausse split tsung command into tsung and tsung-recorder (TSUN-113)
nniclausse authored Mar 5, 2009
142 echo " -v print version information and exit"
143 echo " -h display this help and exit"
c65d43c @nniclausse fix output msg; fix usage.
nniclausse authored Dec 5, 2005
144 exit
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
145 }
146
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
147 while getopts "vhf:l:d:r:i:Fsw:m:" Option
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
148 do
149 case $Option in
7fbd71d @nniclausse check if config file exist
nniclausse authored Mar 31, 2004
150 f) CONF_OPT_FILE=$OPTARG;;
459db7e @nniclausse absolute path needed for logfile name (fix TSUN-57)
nniclausse authored Mar 28, 2008
151 l) # must add absolute path
152 echo "$OPTARG" | grep -q "^/"
153 RES=$?
154 if [ "$RES" == 0 ]; then
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
155 LOG_OPT="log_dir \"$OPTARG/\" "
459db7e @nniclausse absolute path needed for logfile name (fix TSUN-57)
nniclausse authored Mar 28, 2008
156 else
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
157 LOG_OPT="log_dir \"$PWD/$OPTARG/\" "
459db7e @nniclausse absolute path needed for logfile name (fix TSUN-57)
nniclausse authored Mar 28, 2008
158 fi
159 ;;
b4168ce @nniclausse allow outputting stats log to stdout (TSUN-191)
nniclausse authored Sep 16, 2011
160 m) MON_FILE="mon_file \"$OPTARG\"";;
a68c3e6 @nniclausse initial debug level also for controller
nniclausse authored Feb 21, 2006
161 d) DEBUG_LEVEL=$OPTARG;;
95fb173 @nniclausse add -r option to set the command for starting nodes on remote host (s…
nniclausse authored Dec 10, 2004
162 r) ERL_RSH=" -rsh $OPTARG ";;
d38c657 @nniclausse can use FQDN (-name instead of -sname) with -F flag
nniclausse authored Jul 15, 2008
163 F) NAMETYPE="-name";;
c1163bd @nniclausse add gen_server to choose local ports to bypass the 64K limit.
nniclausse authored Mar 5, 2010
164 w) WARM_TIME=$OPTARG;;
239c2c3 @nniclausse add option to enable smp on client beams (controller is already smp)
nniclausse authored Mar 5, 2010
165 s) SMP_DISABLE="false";;
4c0948f @nniclausse split tsung command into tsung and tsung-recorder (TSUN-113)
nniclausse authored Mar 5, 2009
166 v) version;;
e0bd0f1 @nniclausse add an option to set an unique id in the erlang nodes name (TSUN-116)
nniclausse authored Apr 4, 2009
167 i) ID=$OPTARG
168 COOKIE=$COOKIE"_"$ID
169 CONTROLLER=$CONTROLLER"_"$ID
170 ;;
4c0948f @nniclausse split tsung command into tsung and tsung-recorder (TSUN-113)
nniclausse authored Mar 5, 2009
171 h) usage;;
f2c04e9 @nniclausse argh, stupid typo
nniclausse authored Feb 12, 2004
172 *) usage ;;
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
173 esac
3493e62 @nniclausse add parent proxy support for http: first step (TSUN-37)
nniclausse authored Jun 21, 2007
174 done
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
175 shift $(($OPTIND - 1))
176
177 case $1 in
178 start)
0992b82 @nniclausse check if recorder is already running
nniclausse authored Nov 13, 2005
179 checkconfig
180 checkversion
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored Mar 18, 2004
181 maindir
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
182 logdir
183 start
184 ;;
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored Nov 4, 2005
185 boot)
0992b82 @nniclausse check if recorder is already running
nniclausse authored Nov 13, 2005
186 checkversion
187 ;;
0964e94 @nniclausse detect version of erlang in boot script and rebuild them if needed
nniclausse authored Nov 4, 2005
188
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
189 debug)
0992b82 @nniclausse check if recorder is already running
nniclausse authored Nov 13, 2005
190 checkconfig
191 checkversion
1ffd1ec @nniclausse add configure scripts to detect erlang installation directory and com…
nniclausse authored Mar 18, 2004
192 maindir
748e9e0 @nniclausse major source reorganisation to ease debian packaging
nniclausse authored Feb 11, 2004
193 logdir
194 debug
195 ;;
196 stop)
197 stop
198 ;;
199 status)
200 status
201 ;;
202 *)
203 usage $0
204 ;;
205 esac
Something went wrong with that request. Please try again.