Skip to content
Browse files

ability to record a string with 'record_tag' (TSUN-52)

SVN Revision: 786
  • Loading branch information...
1 parent 56050db commit 33626a66e2ae287bba7b664be78824b7617fe3ba @nniclausse nniclausse committed
Showing with 43 additions and 9 deletions.
  1. +26 −7 src/tsung_recorder/ts_proxy_recorder.erl
  2. +1 −1 src/tsung_recorder/tsung_recorder.erl
  3. +16 −1 tsung.sh.in
View
33 src/tsung_recorder/ts_proxy_recorder.erl
@@ -47,7 +47,7 @@
%%--------------------------------------------------------------------
%% External exports
--export([start/1, dorecord/1, stop/1]).
+-export([start/1, dorecord/1, recordtag/1, stop/1]).
%% gen_server callbacks
-export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]).
@@ -61,20 +61,33 @@
%% Description: Starts the server
%%--------------------------------------------------------------------
start(Config) ->
- gen_server:start_link({local, ?MODULE}, ?MODULE, Config, []).
+ gen_server:start_link({global, ?MODULE}, ?MODULE, Config, []).
%%--------------------------------------------------------------------
%% Function: stop/1
%%--------------------------------------------------------------------
-stop(Node) ->
- gen_server:call({?MODULE,Node},{stop}).
+stop(_) ->
+ gen_server:call({global, ?MODULE},{stop}).
%%--------------------------------------------------------------------
%% Function: dorecord/1
%% Description: record a new request
%%--------------------------------------------------------------------
-dorecord(Args) ->
- gen_server:cast(?MODULE,{record, Args}).
+dorecord(Args)->
+ gen_server:cast({global, ?MODULE},{record, Args}).
+
+%%--------------------------------------------------------------------
+%% Function: recordtag/1
+%% Description: record a string (for use on the command line)
+%%--------------------------------------------------------------------
+recordtag([Host,Args]) when is_list(Host)->
+ recordtag(list_to_atom(Host), Args).
+
+%% @spec recordtag/2
+recordtag(Host, Args) when is_list(Args)->
+ _List = net_adm:world_list([Host]),
+ global:sync(),
+ gen_server:cast({global,?MODULE},{record, Args}).
%%====================================================================
%% Server functions
@@ -162,7 +175,13 @@ handle_cast({record, {Request}}, State=#state_rec{plugin=Plugin}) ->
{ok, NewState} = Plugin:record_request(State, Request),
{noreply, NewState#state_rec{timestamp=TimeStamp}};
-handle_cast(_Msg, State) ->
+handle_cast({record, String}, State) when is_list(String)->
+ ?LOGF("Record string ~p~n",[String], ?NOTICE),
+ io:format(State#state_rec.logfd, "~n~s~n", [String]),
+ {noreply, State};
+
+handle_cast(Msg, State) ->
+ ?LOGF("IGNORE Msg ~p~n",[Msg], ?WARN),
{noreply, State}.
%%--------------------------------------------------------------------
View
2 src/tsung_recorder/tsung_recorder.erl
@@ -69,4 +69,4 @@ stop(_State) ->
%%----------------------------------------------------------------------
stop_all(Arg) ->
ts_utils:stop_all(Arg,'ts_proxy_listener', "tsung recorder",
- {ts_proxy_recorder, stop}).
+ fun ts_proxy_recorder:stop/1).
View
17 tsung.sh.in
@@ -43,7 +43,13 @@ stop() {
stop_recorder() {
$ERL $ERL_OPTS $ERL_RSH -noshell -sname killer -setcookie $COOKIE -pa $TSUNGPATH -pa $RECORDERPATH -s tsung_recorder stop_all $HOST -s init stop
- rm $PIDFILE
+ RET=$?
+ if [ $RET == 1 ]; then
+ echo "FAILED"
+ else
+ echo "[OK]"
+ rm $PIDFILE
+ fi
}
recorder_status() {
@@ -139,6 +145,12 @@ status() {
$ERL -noshell -sname $SNAME -setcookie $COOKIE -pa $TSUNGPATH -pa $CONTROLLERPATH -s tsung_controller status $HOST -s init stop
}
+record_tag() {
+ shift
+ SNAME=tsung_recordtag
+ $ERL -noshell -sname $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
@@ -197,6 +209,9 @@ case $1 in
recorder
;;
+ record_tag)
+ record_tag $*
+ ;;
boot)
checkversion
;;

0 comments on commit 33626a6

Please sign in to comment.
Something went wrong with that request. Please try again.