This file is indexed.

/usr/bin/tsung-recorder is in tsung 1.4.2-1.1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/usr/bin/env bash

UNAME=`uname`
case $UNAME in
        "Linux") HOST=`hostname -s`;;
        "SunOS") HOST=`hostname`;;
        *) HOST=`hostname -s`;;
esac

INSTALL_DIR=/usr/lib/erlang/
ERL=/usr/bin/erl
MAIN_DIR=$HOME/.tsung
LOG_DIR=$MAIN_DIR/log
LOG_OPT="log_file \"$LOG_DIR/tsung.log\""
VERSION=1.4.2
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
CONTROLLERPATH=$INSTALL_DIR/lib/tsung_controller-$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  "
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 <options> start|stop|restart"
    echo "Options:"
    echo "    -p <plugin>    plugin used for the recorder"
    echo "                     available: http, pgsql,webdav (default is http)"
    echo "    -L <port>      listening port for the recorder (default is 8090)"
    echo "    -I <IP>        for the pgsql recorder (or parent proxy): server IP"
    echo "                      (default  is 127.0.0.1)"
    echo "    -P <port>      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 <level>     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
        start
        ;;

    record_tag)
        record_tag $*
        ;;
    boot)
        checkversion
        ;;
    stop)
        PIDFILE="/tmp/tsung_recorder.pid"
        stop
        ;;
    status)
        status
        ;;
    restart)
        stop
        start
        ;;
    *)
        usage $0
        ;;
esac