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