From 4c0948f4ac1de30e442f9b910a74a39cef22db72 Mon Sep 17 00:00:00 2001 From: Nicolas Niclausse Date: Thu, 5 Mar 2009 16:15:17 +0000 Subject: [PATCH] split tsung command into tsung and tsung-recorder (TSUN-113) SVN Revision: 995 --- Makefile.in | 16 +-- configure | 3 +- configure.in | 1 + debian/control | 2 +- doc/tsung-recorder.1 | 75 ++++++++++++++ doc/tsung-recorder.1.sgml | 156 ++++++++++++++++++++++++++++ doc/tsung.1 | 38 ++----- doc/tsung.1.sgml | 61 ++--------- tsung-recorder.sh.in | 208 ++++++++++++++++++++++++++++++++++++++ tsung.sh.in | 108 +++----------------- tsung.spec.in | 1 + 11 files changed, 483 insertions(+), 186 deletions(-) create mode 100644 doc/tsung-recorder.1 create mode 100644 doc/tsung-recorder.1.sgml create mode 100644 tsung-recorder.sh.in diff --git a/Makefile.in b/Makefile.in index 430691519..ada5b17d6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -143,25 +143,26 @@ RECORDER_TGT_APPFILES_P = priv/$(RECORDER_APPLICATION)* CONTROLLER_TGT_APPFILES_P = priv/$(CONTROLLER_APPLICATION)* SCRIPT = $(BINDIR)/tsung +REC_SCRIPT = $(BINDIR)/tsung-recorder PWD = $(shell pwd) -BUILD_OPTIONS = '[{systools, \ +BUILD_OPTIONS = '[{systools, \ [{variables,[ \ {"TSUNGPATH", "$(PWD)/temp/"}] \ }]}, \ - {sh_script, none}, \ + {sh_script, none}, \ {make_app, true }, {make_rel, true}].' BUILD_OPTIONS_DOT = $(subst $(PWD)/temp/,./,$(BUILD_OPTIONS)) BUILD_OPTIONS_FILE = ./BUILD_OPTIONS -DIST_COMMON=Makefile.in $(CONFFILE_SRC) $(PERL_SCRIPTS_SRC) $(PYTHON_SCRIPTS_SRC) tsung.sh.in tsung.spec.in $(CONTROLLER_SRC_APPFILES_IN) +DIST_COMMON=Makefile.in $(CONFFILE_SRC) $(PERL_SCRIPTS_SRC) $(PYTHON_SCRIPTS_SRC) tsung.sh.in tsung-recorder.sh.in tsung.spec.in $(CONTROLLER_SRC_APPFILES_IN) DOC_OPTS={def,{version,\"$(VERSION)\"}} .PHONY: doc -tsung: Makefile config.status $(PERL_SCRIPTS) $(PYTHON_SCRIPTS) tsung.sh tsung.spec $(TARGET) $(RECORDER_TARGET) $(CONTROLLER_TARGET) $(LIB_TARGET) $(CONTROLLER_SRC_APPFILES) $(SRC_APPFILES) $(RECORDER_SRC_APPFILES) +tsung: Makefile config.status $(PERL_SCRIPTS) $(PYTHON_SCRIPTS) tsung.sh tsung-recorder.sh tsung.spec $(TARGET) $(RECORDER_TARGET) $(CONTROLLER_TARGET) $(LIB_TARGET) $(CONTROLLER_SRC_APPFILES) $(SRC_APPFILES) $(RECORDER_SRC_APPFILES) buildtest: $(TEST_TARGET) @@ -205,8 +206,8 @@ deb: clean: -cd priv && rm -f $(shell ls priv | grep -v builder\.erl| grep -v CVS) && cd .. -rm -f $(TARGET) $(TMP) $(BUILD_OPTIONS_FILE) builder.beam - -rm -f $(TGT_APPFILES) tsung.sh $(PERL_SCRIPTS) $(PYTHON_SCRIPTS) $(CONFFILE) - -rm -f ebin/*.beam tsung.sh tsung.spec tsung.xml + -rm -f $(TGT_APPFILES) $(PERL_SCRIPTS) $(PYTHON_SCRIPTS) $(CONFFILE) + -rm -f ebin/*.beam tsung.sh tsung.spec tsung.xml tsung.sh tsung-recorder.sh install: doc boot install_recorder install_controller $(CONFFILE) -rm -f $(TMP) @@ -241,6 +242,7 @@ install: doc boot install_recorder install_controller $(CONFFILE) # create startup script install -m 0755 tsung.sh $(SCRIPT) + install -m 0755 tsung-recorder.sh $(REC_SCRIPT) install -m 0755 $(PERL_SCRIPTS) $(TOOLS_BINDIR) # tsung-plotter install -m 0755 $(PYTHON_SCRIPTS) $(TOOLS_BINDIR) @@ -390,7 +392,7 @@ release: Makefile tsung.spec doc $(DEBIAN) $(PERL_SCRIPTS_SRC) CONTRIBUTORS CHANGES \ $(PYTHON_SCRIPTS_SRC) $(TSUNG_PLOTTER_CONF) $(TSUNG_PLOTTER_LIB)\ configure configure.in config.guess *.m4 config.sub Makefile.in \ - install-sh tsung.spec.in tsung.spec + install-sh tsung.spec.in tsung.spec tsung-recorder.sh.in tar -C $(distdir) -zxf tmp.tgz mkdir $(distdir)/ebin tar zvcf $(distdir).tar.gz $(distdir) diff --git a/configure b/configure index f0109757e..943f61f15 100755 --- a/configure +++ b/configure @@ -3073,7 +3073,7 @@ echo "$as_me: Storing library files in $EXPANDED_LIBDIR" >&6;} { echo "$as_me:$LINENO: Storing data files in $EXPANDED_SHAREDIR" >&5 echo "$as_me: Storing data files in $EXPANDED_SHAREDIR" >&6;} -ac_config_files="$ac_config_files Makefile tsung.spec tsung.sh examples/*.xml src/tsung_stats.pl src/tsung-plotter/tsplot.py src/log2tsung.pl src/tsung_controller/tsung_controller.app.src src/tsung_recorder/tsung_recorder.app.src src/tsung/tsung.app.src" +ac_config_files="$ac_config_files Makefile tsung.spec tsung.sh tsung-recorder.sh examples/*.xml src/tsung_stats.pl src/tsung-plotter/tsplot.py src/log2tsung.pl src/tsung_controller/tsung_controller.app.src src/tsung_recorder/tsung_recorder.app.src src/tsung/tsung.app.src" cat >confcache <<\_ACEOF @@ -3647,6 +3647,7 @@ do "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; "tsung.spec") CONFIG_FILES="$CONFIG_FILES tsung.spec" ;; "tsung.sh") CONFIG_FILES="$CONFIG_FILES tsung.sh" ;; + "tsung-recorder.sh") CONFIG_FILES="$CONFIG_FILES tsung-recorder.sh" ;; "examples/*.xml") CONFIG_FILES="$CONFIG_FILES examples/*.xml" ;; "src/tsung_stats.pl") CONFIG_FILES="$CONFIG_FILES src/tsung_stats.pl" ;; "src/tsung-plotter/tsplot.py") CONFIG_FILES="$CONFIG_FILES src/tsung-plotter/tsplot.py" ;; diff --git a/configure.in b/configure.in index aa994e1ea..b10bb95a1 100644 --- a/configure.in +++ b/configure.in @@ -106,6 +106,7 @@ AC_CONFIG_FILES([\ Makefile \ tsung.spec \ tsung.sh \ + tsung-recorder.sh \ examples/*.xml \ src/tsung_stats.pl \ src/tsung-plotter/tsplot.py \ diff --git a/debian/control b/debian/control index 2b8cd17ea..f4e8ef802 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Standards-Version: 3.6.0 Package: tsung Architecture: all Depends: erlang (>= 9.2-1), libxmerl-erlang (>= 0.19-1) | erlang (>= 10.b.5-1) -Recommends: gnuplot, perl, ssh, libtemplate-perl +Recommends: gnuplot, perl, ssh, libtemplate-perl, python-matplotlib Description: A distributed multi-protocol load testing tool. Tsung is a distributed load testing tool. It is protocol-independent and can currently be used to stress and diff --git a/doc/tsung-recorder.1 b/doc/tsung-recorder.1 new file mode 100644 index 000000000..f73334e01 --- /dev/null +++ b/doc/tsung-recorder.1 @@ -0,0 +1,75 @@ +.\" This manpage has been automatically generated by docbook2man +.\" from a DocBook document. This tool can be found at: +.\" +.\" Please send any bug reports, improvements, comments, patches, +.\" etc. to Steve Cheng . +.TH "TSUNG-RECORDER" "1" "05 mars 2009" "" "" + +.SH NAME +tsung-recorder \- Proxy recorder for the tsung load testing tool. +.SH SYNOPSIS + +\fBtsung-recorder\fR [ \fB-l log file\fR ] [ \fB-r command\fR ] [ \fB-p plugin\fR ] [ \fB-L listen port\fR ] [ \fB-I IP\fR ] [ \fB-P port\fR ] [ \fB-u \fR ] [ \fBstart|stop|restart|record_tag\fR ] + +.SH "DESCRIPTION" +.PP +\fBtsung\fR is a distributed load testing +tool. It is protocol-independent and can currently be used to +stress and benchmark HTTP, WebDAV, LDAP, PostgreSQL, MySQL and +Jabber/XMPP servers. \fBtsung-recorder\fR can be +used to record sessions (only for HTTP, WebDAV and Postgresql) that can be edited and replayed later by tsung +.PP +tsung-recorder is a proxy that records a session in the +tsung native XML format; it can be used by your favorite client (browser in the case of the http plugin). +.TP +\fBstart\fR +start the proxy recorder (listening port is 8090). By default the HTTP recorder is started. With the -p option, you can select another plugin. The resulting files will be created as \fI~/.tsung/tsung_recorderYYYMMDD-HH:MM.xml\fR; if it doesn't work, take a look at \fI~/.tsung/log/tsung.log-tsunami_recorder@hostname\fR +.TP +\fBstop\fR +stop the proxy recorder +.TP +\fBrecord_tag value\fR +add a string (comment or tag) while recording a +session. This is useful for example to add transaction tag +while recording a session. +.SH "MANUAL" +.PP +A manual should be available at +\fI/usr/share/doc/tsung/user_manual.html\fR\&. It +is also available online at +http://tsung.erlang-projects.org/user_manual.html +.SH "OPTIONS" +.TP +\fB-l\fR +Specifies the log file to use. The default log file name is \fI~/tsung/log/tsung.log\fR +.TP +\fB-p\fR +Specifies the plugin used for the recorder. Default is http, available: http, pgsql,webdav +.TP +\fB-L\fR +Listening port for the recorder. Default is 8090 +.TP +\fB-I\fR +For the pgsql recorder (or parent proxy): server IP. default is 127.0.0.1 +.TP +\fB-P\fR +For the pgsql recorder (or parent proxy): server port. Default is 5432 +.TP +\fB-u\fR +For the http recorder: use a parent proxy +.SH "BUGS" +.PP +Please reports bugs to the mailing list +, see +https://lists.process-one.net/mailman/listinfo/tsung-users for +archives. +.SH "SEE ALSO" +.PP +\fIerlang\fR(3) +and \fItsung\fR(3) +.SH "AUTHORS" +.PP +\fBTsung\fR is written by Nicolas Niclausse +\&. Contributors list +is available in +\fI/usr/share/doc/tsung/CONTRIBUTORS\fR diff --git a/doc/tsung-recorder.1.sgml b/doc/tsung-recorder.1.sgml new file mode 100644 index 000000000..d985dc848 --- /dev/null +++ b/doc/tsung-recorder.1.sgml @@ -0,0 +1,156 @@ + + + +
+ nicolas.niclausse@niclux.org +
+ + Nicolas + Niclausse + + March 2009 + + 2009 + Nicolas Niclausse + +
+ + + tsung-recorder + 1 + + + + tsung-recorder + +Proxy recorder for the tsung load testing tool. + + + + + + tsung-recorder + log file + command + plugin + listen port + IP + port + + start|stop|restart|record_tag + + + + + description + + tsung is a distributed load testing + tool. It is protocol-independent and can currently be used to + stress and benchmark HTTP, WebDAV, LDAP, PostgreSQL, MySQL and + Jabber/XMPP servers. tsung-recorder can be + used to record sessions (only for HTTP, WebDAV and Postgresql) that can be edited and replayed later by tsung + + tsung-recorder is a proxy that records a session in the + tsung native XML format; it can be used by your favorite client (browser in the case of the http plugin). + + + + + + start the proxy recorder (listening port is 8090). By default the HTTP recorder is started. With the -p option, you can select another plugin. The resulting files will be created as ~/.tsung/tsung_recorderYYYMMDD-HH:MM.xml; if it doesn't work, take a look at ~/.tsung/log/tsung.log-tsunami_recorder@hostname + + + + + + stop the proxy recorder + + + + value + + add a string (comment or tag) while recording a + session. This is useful for example to add transaction tag + while recording a session. + + + + + + + manual A manual should be available at + /usr/share/doc/tsung/user_manual.html. It + is also available online at +
http://tsung.erlang-projects.org/user_manual.html
+
+
+ + + options + + + + + Specifies the log file to use. The default log file name is ~/tsung/log/tsung.log + + + + + + Specifies the plugin used for the recorder. Default is http, available: http, pgsql,webdav + + + + + + Listening port for the recorder. Default is 8090 + + + + + + For the pgsql recorder (or parent proxy): server IP. default is 127.0.0.1 + + + + + + For the pgsql recorder (or parent proxy): server port. Default is 5432 + + + + + + For the http recorder: use a parent proxy + + + + + + + Bugs Please reports bugs to the mailing list + tsung-users@process-one.net, see +
https://lists.process-one.net/mailman/listinfo/tsung-users
for + archives. +
+
+ + + see also + +erlang3 + and tsung3 + + + + + Authors + + Tsung is written by Nicolas Niclausse + nicolas@niclux.org. Contributors list + is available in + /usr/share/doc/tsung/CONTRIBUTORS + + + +
diff --git a/doc/tsung.1 b/doc/tsung.1 index ee285d215..27ba29620 100644 --- a/doc/tsung.1 +++ b/doc/tsung.1 @@ -3,13 +3,13 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "TSUNG" "1" "01 September 2008" "" "" +.TH "TSUNG" "1" "05 mars 2009" "" "" .SH NAME tsung \- A distributed multi-protocol load testing tool. .SH SYNOPSIS -\fBtsung\fR [ \fB-f configuration file\fR ] [ \fB-l log file\fR ] [ \fB-r command\fR ] [ \fB-p plugin\fR ] [ \fB-L listen port\fR ] [ \fB-I IP\fR ] [ \fB-P port\fR ] [ \fB-u \fR ] [ \fBstart|stop|restart|debug|status|recorder|record_tag|stop_recorder\fR ] +\fBtsung\fR [ \fB-f configuration file\fR ] [ \fB-l log file\fR ] [ \fB-r command\fR ] [ \fB-v\fR ] [ \fB-h\fR ] [ \fBstart|stop|restart|debug|status\fR ] .SH "DESCRIPTION" .PP @@ -26,8 +26,6 @@ For HTTP, it supports 1.0 and 1.1, has a proxy mode to record sessions, supports GET and POST methods, Cookies, and Basic WWW-authentication. It also has support for SSL. .PP -There are two applications builtin with this script: the load testing tool, and the proxy recorder. -.PP Several config examples can be found in \fI/usr/share/doc/tsung/examples/\fR\&. .TP @@ -35,24 +33,13 @@ Several config examples can be found in start tsung load testing .TP \fBdebug\fR -start tsung with an erlang shell +start tsung with an interactive erlang shell .TP \fBstop\fR stop tsung .TP -\fBrecorder\fR -start the proxy recorder (listening port is 8090). By default the HTTP recorder is started. With the -p option, you can select another plugin. The resulting files will be created as \fI~/.tsung/tsung_recorderYYYMMDD-HH:MM.xml\fR; if it doesn't work, take a look at \fI~/.tsung/log/tsung.log-tsunami_recorder@hostname\fR -.TP -\fBstop_recorder\fR -stop the proxy recorder -.TP \fBstatus\fR -print current status of tsung -.TP -\fBrecord_tag value\fR -add a string (comment or tag) while recording a -session. This is useful for example to add transaction tag -while recording a session. +print current status of a running instance of tsung (must be run on the controller host) .SH "MANUAL" .PP A manual should be available at @@ -70,20 +57,11 @@ Specifies the log file to use. The default log file name is \fI~/tsung/log/tsung \fB-r\fR Specifies an alternative to ssh (rsh for ex.) for starting a slave node on a remote host .TP -\fB-p\fR -Specifies the plugin used for the recorder. Default is http, available: http, pgsql,webdav -.TP -\fB-L\fR -Listening port for the recorder. Default is 8090 -.TP -\fB-I\fR -For the pgsql recorder (or parent proxy): server IP. default is 127.0.0.1 -.TP -\fB-P\fR -For the pgsql recorder (or parent proxy): server port. Default is 5432 +\fB-v\fR +Show version .TP -\fB-u\fR -For the http recorder: use a parent proxy +\fB-h\fR +Show usage .SH "BUGS" .PP Please reports bugs to the mailing list diff --git a/doc/tsung.1.sgml b/doc/tsung.1.sgml index 8363342ec..9b12a28d3 100644 --- a/doc/tsung.1.sgml +++ b/doc/tsung.1.sgml @@ -33,12 +33,9 @@ A distributed multi-protocol load testing tool. configuration file log file command - plugin - listen port - IP - port - - start|stop|restart|debug|status|recorder|record_tag|stop_recorder + + + start|stop|restart|debug|status @@ -58,8 +55,6 @@ A distributed multi-protocol load testing tool. record sessions, supports GET and POST methods, Cookies, and Basic WWW-authentication. It also has support for SSL. - There are two applications builtin with this script: the load testing tool, and the proxy recorder. - Several config examples can be found in /usr/share/doc/tsung/examples/. @@ -75,7 +70,7 @@ A distributed multi-protocol load testing tool. - start tsung with an erlang shell + start tsung with an interactive erlang shell @@ -84,30 +79,10 @@ A distributed multi-protocol load testing tool. stop tsung - - - - start the proxy recorder (listening port is 8090). By default the HTTP recorder is started. With the -p option, you can select another plugin. The resulting files will be created as ~/.tsung/tsung_recorderYYYMMDD-HH:MM.xml; if it doesn't work, take a look at ~/.tsung/log/tsung.log-tsunami_recorder@hostname - - - - - - stop the proxy recorder - - - print current status of tsung - - - - value - - add a string (comment or tag) while recording a - session. This is useful for example to add transaction tag - while recording a session. + print current status of a running instance of tsung (must be run on the controller host) @@ -143,33 +118,15 @@ A distributed multi-protocol load testing tool. - - - Specifies the plugin used for the recorder. Default is http, available: http, pgsql,webdav - - - - - - Listening port for the recorder. Default is 8090 - - - - - - For the pgsql recorder (or parent proxy): server IP. default is 127.0.0.1 - - - - + - For the pgsql recorder (or parent proxy): server port. Default is 5432 + Show version - + - For the http recorder: use a parent proxy + Show usage diff --git a/tsung-recorder.sh.in b/tsung-recorder.sh.in new file mode 100644 index 000000000..ae1266d13 --- /dev/null +++ b/tsung-recorder.sh.in @@ -0,0 +1,208 @@ +#!/usr/bin/env bash + +UNAME=`uname` +case $UNAME in + "Linux") HOST=`hostname -s`;; + "SunOS") HOST=`hostname`;; + *) HOST=`hostname -s`;; +esac + +INSTALL_DIR=@prefix@/lib/erlang/ +ERL=@ERL@ +MAIN_DIR=$HOME/.tsung +LOG_DIR=$MAIN_DIR/log +LOG_OPT="log_file \"$LOG_DIR/tsung.log\"" +VERSION=@PACKAGE_VERSION@ +NAMETYPE="-sname" + +LISTEN_PORT=8090 +USE_PARENT_PROXY=false +PGSQL_SERVER_IP=127.0.0.1 +PGSQL_SERVER_PORT=5432 +NAME=tsung +RECORDER=tsung_recorder + +TSUNGPATH=$INSTALL_DIR/lib/tsung-$VERSION/ebin +RECORDERPATH=$INSTALL_DIR/lib/tsung_recorder-$VERSION/ebin + +CONF_OPT_FILE="$HOME/.tsung/tsung.xml" +BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_controller-$VERSION/priv/tsung_controller -boot_var TSUNGPATH $INSTALL_DIR " +REC_BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_recorder-$VERSION/priv/tsung_recorder -boot_var TSUNGPATH $INSTALL_DIR " +DEBUG_LEVEL=5 +RECORDER_PLUGIN="http" +ERL_RSH=" -rsh ssh " +ERL_OPTS=" -smp auto +P 250000 +A 16 +K true @ERL_OPTS@ " +COOKIE='tsung' +ERTS_RUN=`$ERL -version 2>&1 | tr -cd 0123456789.` +ERTS_BOOT=`grep erts $TSUNGPATH/../priv/tsung.rel 2> /dev/null| tr -cd 0123456789.` + +stop() { + $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE killer -setcookie $COOKIE -pa $TSUNGPATH -pa $RECORDERPATH -s tsung_recorder stop_all $HOST -s init stop + RET=$? + if [ $RET == 1 ]; then + echo "FAILED" + else + echo "[OK]" + rm $PIDFILE + fi +} + +status() { + PIDFILE="/tmp/tsung_recorder.pid" + if [ -f $PIDFILE ]; then + echo "Tsung recorder started [OK]" + else + echo "Tsung recorder not started " + fi +} + +checkversion() { + if [ $ERTS_RUN != $ERTS_BOOT ] + then + echo "Erlang version has changed ! [$ERTS_BOOT] != [$ERTS_RUN]" + echo "Must create new boot files (you may have to run this one time as root ! )" + makebootfiles + fi +} + +makebootfiles() { + echo "creating boot file for tsung_recorder application" + cd $RECORDERPATH/.. + $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null +} + +start() { + echo "Starting Tsung recorder on port $LISTEN_PORT" + $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE $RECORDER -setcookie $COOKIE $REC_BOOT_OPT \ + -pa $TSUNGPATH -pa $RECORDERPATH -pa $CONTROLLERPATH \ + -tsung_recorder debug_level $DEBUG_LEVEL \ + -tsung_recorder $LOG_OPT \ + -tsung_recorder parent_proxy $USE_PARENT_PROXY \ + -tsung_recorder plugin ts_proxy_$RECORDER_PLUGIN \ + -tsung_recorder proxy_log_file \"$MAIN_DIR/tsung_recorder.xml\" \ + -tsung_recorder pgsql_server \"${PGSQL_SERVER_IP}\" \ + -tsung_recorder pgsql_port ${PGSQL_SERVER_PORT} \ + -tsung_recorder proxy_listen_port $LISTEN_PORT & + echo $! > /tmp/tsung_recorder.pid +} + +version() { + echo "Tsung Recorder version $VERSION" + exit 0 +} + +checkconfig() { + if [ ! -e $CONF_OPT_FILE ] + then + echo "Config file $CONF_OPT_FILE doesn't exist, aborting !" + exit 1 + fi +} + +maindir() { + if [ ! -d $MAIN_DIR ] + then + echo "Creating local Tsung directory $MAIN_DIR" + mkdir $MAIN_DIR + fi +} + +logdir() { + if [ ! -d $LOG_DIR ] + then + echo "Creating Tsung log directory $LOG_DIR" + mkdir $LOG_DIR + fi +} + +record_tag() { + shift + SNAME=tsung_recordtag + $ERL -noshell $NAMETYPE $SNAME -setcookie $COOKIE -pa $TSUNGPATH -pa $RECORDERPATH -run ts_proxy_recorder recordtag $HOST "$*" -s init stop +} + +checkrunning(){ + if [ -f $PIDFILE ]; then + CURPID=`cat $PIDFILE` + if kill -0 $CURPID 2> /dev/null ; then + echo "Can't start: Tsung recorder already running !" + exit 1 + fi + fi +} + +usage() { + prog=`basename $0` + echo "Usage: $prog start|stop|restart" + echo "Options:" + echo " -p plugin used for the recorder" + echo " available: http, pgsql,webdav (default is http)" + echo " -L listening port for the recorder (default is 8090)" + echo " -I for the pgsql recorder (or parent proxy): server IP" + echo " (default is 127.0.0.1)" + echo " -P for the pgsql recorder (or parent proxy): server port" + echo " (default is 5432)" + echo " -u for the http recorder: use a parent proxy" + echo " -d set log level from 0 to 7 (default is 5)" + echo " -v print version information and exit" + echo " -h display this help and exit" + exit +} + +while getopts "hvf:p:l:d:r:i:P:L:I:u:" Option +do + case $Option in + f) CONF_OPT_FILE=$OPTARG;; + l) # must add absolute path + echo "$OPTARG" | grep -q "^/" + RES=$? + if [ "$RES" == 0 ]; then + LOG_OPT="log_file \"$OPTARG\" " + else + LOG_OPT="log_file \"$PWD/$OPTARG\" " + fi + ;; + d) DEBUG_LEVEL=$OPTARG;; + p) RECORDER_PLUGIN=$OPTARG;; + I) PGSQL_SERVER_IP=$OPTARG;; + u) USE_PARENT_PROXY=true;; + P) PGSQL_SERVER_PORT=$OPTARG;; + L) LISTEN_PORT=$OPTARG;; + v) version;; + h) usage;; + *) usage ;; + esac +done +shift $(($OPTIND - 1)) + +case $1 in + start) + PIDFILE="/tmp/tsung_recorder.pid" + checkversion + maindir + logdir + checkrunning + recorder + ;; + + record_tag) + record_tag $* + ;; + boot) + checkversion + ;; + stop) + PIDFILE="/tmp/tsung_recorder.pid" + stop_recorder + ;; + status) + recorder_status + ;; + restart) + stop + start + ;; + *) + usage $0 + ;; +esac diff --git a/tsung.sh.in b/tsung.sh.in index 9361a46e0..8ec5ecdf4 100755 --- a/tsung.sh.in +++ b/tsung.sh.in @@ -21,48 +21,24 @@ PGSQL_SERVER_IP=127.0.0.1 PGSQL_SERVER_PORT=5432 NAME=tsung CONTROLLER=tsung_controller -RECORDER=tsung_recorder SMP_DISABLE=true TSUNGPATH=$INSTALL_DIR/lib/tsung-$VERSION/ebin CONTROLLERPATH=$INSTALL_DIR/lib/tsung_controller-$VERSION/ebin -RECORDERPATH=$INSTALL_DIR/lib/tsung_recorder-$VERSION/ebin CONF_OPT_FILE="$HOME/.tsung/tsung.xml" BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_controller-$VERSION/priv/tsung_controller -boot_var TSUNGPATH $INSTALL_DIR " -REC_BOOT_OPT="-boot $INSTALL_DIR/lib/tsung_recorder-$VERSION/priv/tsung_recorder -boot_var TSUNGPATH $INSTALL_DIR " DEBUG_LEVEL=5 -RECORDER_PLUGIN="http" ERL_RSH=" -rsh ssh " ERL_OPTS=" -smp auto +P 250000 +A 16 +K true @ERL_OPTS@ " COOKIE='tsung' ERTS_RUN=`$ERL -version 2>&1 | tr -cd 0123456789.` -ERTS_BOOT=`grep erts $TSUNGPATH/../priv/tsung.rel | tr -cd 0123456789.` +ERTS_BOOT=`grep erts $TSUNGPATH/../priv/tsung.rel 2> /dev/null| tr -cd 0123456789.` stop() { $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE killer -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller stop_all $HOST -s init stop } -stop_recorder() { - $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE killer -setcookie $COOKIE -pa $TSUNGPATH -pa $RECORDERPATH -s tsung_recorder stop_all $HOST -s init stop - RET=$? - if [ $RET == 1 ]; then - echo "FAILED" - else - echo "[OK]" - rm $PIDFILE - fi -} - -recorder_status() { - PIDFILE="/tmp/tsung_recorder.pid" - if [ -f $PIDFILE ]; then - echo "Tsung recorder started [OK]" - else - echo "Tsung recorder not started " - fi -} - checkversion() { if [ $ERTS_RUN != $ERTS_BOOT ] then @@ -79,9 +55,6 @@ makebootfiles() { cd $CONTROLLERPATH/.. echo "creating boot file for tsung_controller application" $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null - echo "creating boot file for tsung_recorder application" - cd $RECORDERPATH/.. - $ERL $ERL_OPTS -noshell -pa $TSUNGPATH -s builder go -s init stop > /dev/null } start() { @@ -93,21 +66,6 @@ start() { -tsung_controller config_file \"$CONF_OPT_FILE\" -tsung_controller $LOG_OPT } -recorder() { - echo "Starting Tsung recorder on port $LISTEN_PORT" - $ERL $ERL_OPTS $ERL_RSH -noshell $NAMETYPE $RECORDER -setcookie $COOKIE $REC_BOOT_OPT \ - -pa $TSUNGPATH -pa $RECORDERPATH -pa $CONTROLLERPATH \ - -tsung_recorder debug_level $DEBUG_LEVEL \ - -tsung_recorder $LOG_OPT \ - -tsung_recorder parent_proxy $USE_PARENT_PROXY \ - -tsung_recorder plugin ts_proxy_$RECORDER_PLUGIN \ - -tsung_recorder proxy_log_file \"$MAIN_DIR/tsung_recorder.xml\" \ - -tsung_recorder pgsql_server \"${PGSQL_SERVER_IP}\" \ - -tsung_recorder pgsql_port ${PGSQL_SERVER_PORT} \ - -tsung_recorder proxy_listen_port $LISTEN_PORT & - echo $! > /tmp/tsung_recorder.pid -} - debug() { $ERL $ERL_OPTS $ERL_RSH $NAMETYPE $CONTROLLER -setcookie $COOKIE $BOOT_OPT \ -pa $TSUNGPATH -pa $CONTROLLERPATH \ @@ -116,7 +74,8 @@ debug() { } version() { - echo "Tsung version $VERSION" + echo "Tsung version $VERSION" + exit 0 } checkconfig() { @@ -148,12 +107,6 @@ status() { $ERL -noshell $NAMETYPE $SNAME -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller status $HOST -s init stop } -record_tag() { - shift - SNAME=tsung_recordtag - $ERL -noshell $NAMETYPE $SNAME -setcookie $COOKIE -pa $TSUNGPATH -pa $RECORDERPATH -run ts_proxy_recorder recordtag $HOST "$*" -s init stop -} - checkrunning_controller() { RES=`status` if [ "$RES" != "Tsung is not started" ]; then @@ -162,23 +115,19 @@ checkrunning_controller() { fi } -checkrunning(){ - if [ -f $PIDFILE ]; then - CURPID=`cat $PIDFILE` - if kill -0 $CURPID 2> /dev/null ; then - echo "Can't start: Tsung recorder already running !" - exit 1 - fi - fi -} - usage() { prog=`basename $0` - echo "$prog start|stop|restart|debug|status|recorder|stop_recorder|version" + echo "Usage: $prog start|stop|debug|status" + echo "Options:" + echo " -f set configuration file (default is ~/.tsung/tsung.xml)" + echo " -l set log file (default is ~/.tsung/log/tsung.log)" + echo " -r set remote connector (default is ssh)" + echo " -v print version information and exit" + echo " -h display this help and exit" exit } -while getopts ":f:p:l:d:r:i:P:L:I:u:F" Option +while getopts "vhf:p:l:d:r:i:P:L:I:u:F" Option do case $Option in f) CONF_OPT_FILE=$OPTARG;; @@ -193,12 +142,9 @@ do ;; d) DEBUG_LEVEL=$OPTARG;; r) ERL_RSH=" -rsh $OPTARG ";; - p) RECORDER_PLUGIN=$OPTARG;; - I) PGSQL_SERVER_IP=$OPTARG;; - u) USE_PARENT_PROXY=true;; F) NAMETYPE="-name";; - P) PGSQL_SERVER_PORT=$OPTARG;; - L) LISTEN_PORT=$OPTARG;; + v) version;; + h) usage;; *) usage ;; esac done @@ -212,18 +158,6 @@ case $1 in logdir start ;; - recorder) - PIDFILE="/tmp/tsung_recorder.pid" - checkversion - maindir - logdir - checkrunning - recorder - ;; - - record_tag) - record_tag $* - ;; boot) checkversion ;; @@ -235,28 +169,12 @@ case $1 in logdir debug ;; - stop) stop ;; - stop_recorder) - PIDFILE="/tmp/tsung_recorder.pid" - stop_recorder - ;; - status) - recorder_status status ;; - - restart) - stop - start - ;; - version) - version - ;; - *) usage $0 ;; diff --git a/tsung.spec.in b/tsung.spec.in index 5cf9ed3f8..6c9b2e65d 100644 --- a/tsung.spec.in +++ b/tsung.spec.in @@ -52,6 +52,7 @@ rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) /usr/bin/tsung +/usr/bin/tsung-recorder /usr/lib/erlang/lib /usr/lib/tsung /usr/share/tsung