Skip to content

Commit

Permalink
add direct ip support, and you don't need set up hostname & ip relati…
Browse files Browse the repository at this point in the history
…ons within /etc/hosts file any more, without the dns server support now
  • Loading branch information
weibomobile committed Jul 13, 2016
1 parent 89678d0 commit cdde130
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 10 deletions.
21 changes: 17 additions & 4 deletions src/tsung_controller/ts_config.erl
Expand Up @@ -214,6 +214,7 @@ parse(Element = #xmlElement{name=load, attributes=Attrs}, Conf) ->
parse(Element = #xmlElement{name=client, attributes=Attrs},
Conf = #config{clients=CList}) ->
Host = getAttr(Attrs, host),
HostIP = getAttr(Attrs, hostip),
Weight = getAttr(integer,Attrs, weight,1),
MaxUsers = getAttr(integer,Attrs, maxusers, 800),
SingleNode = getAttr(atom, Attrs, use_controller_vm, false) or Conf#config.use_controller_vm,
Expand Down Expand Up @@ -263,12 +264,24 @@ parse(Element = #xmlElement{name=client, attributes=Attrs},
1;
{Val, _} -> Val
end,
%% must be hostname and not ip:
case ts_utils:is_ip(Host) of
true ->
%% if the node()'s hostname is ip, then we will got the hostip replace the host attr
{ok, MasterHostname} = ts_utils:node_to_hostname(node()),
case {ts_utils:is_ip(MasterHostname), ts_utils:is_ip(Host), ts_utils:is_ip(HostIP)} of
%% must be hostname and not ip:
{false, true, _} ->
io:format(standard_error,"ERROR: client config: 'host' attribute must be a hostname, "++ "not an IP ! (was ~p)~n",[Host]),
exit({error, badhostname});
false ->
{true, true, _} ->
%% add a new client for each CPU
lists:duplicate(CPU,#client{host = Host,
weight = Weight/CPU,
maxusers = MaxUsers});
{true, _, true} ->
%% add a new client for each CPU
lists:duplicate(CPU,#client{host = HostIP,
weight = Weight/CPU,
maxusers = MaxUsers});
{_, _, _} ->
%% add a new client for each CPU
lists:duplicate(CPU,#client{host = Host,
weight = Weight/CPU,
Expand Down
1 change: 1 addition & 0 deletions tsung-1.0.dtd
Expand Up @@ -29,6 +29,7 @@
cpu NMTOKEN "1"
type (machine | batch) "machine"
host NMTOKEN #IMPLIED
hostip CDATA ""
batch (torque | pbs | lsf | oar) #IMPLIED
scan_intf NMTOKEN #IMPLIED
maxusers NMTOKEN "800"
Expand Down
18 changes: 12 additions & 6 deletions tsung.sh.in
Expand Up @@ -30,6 +30,7 @@ PGSQL_SERVER_IP=127.0.0.1
PGSQL_SERVER_PORT=5432
NAME=tsung
CONTROLLER=tsung_controller
CONTROLLER_EXTENDS=""
SMP_DISABLE=true
WARM_TIME=1
MAX_PROCESS=250000
Expand Down Expand Up @@ -60,7 +61,7 @@ stop() {

view() {
echo "Starting Tsung web only on port 8091"
$ERL $ERL_OPTS $ERL_RSH -noshell $PROTO_DIST $NAMETYPE $CONTROLLER -setcookie $COOKIE \
$ERL $ERL_OPTS $ERL_RSH -noshell $PROTO_DIST $NAMETYPE $CONTROLLER$CONTROLLER_EXTENDS -setcookie $COOKIE \
+P $MAX_PROCESS \
-kernel inet_dist_listen_min $ERL_DIST_PORTS_MIN -kernel inet_dist_listen_max $ERL_DIST_PORTS_MAX \
-s ts_web \
Expand All @@ -72,7 +73,7 @@ view() {

start() {
echo "Starting Tsung"
$ERL $ERL_OPTS $ERL_RSH -noshell $PROTO_DIST $NAMETYPE $CONTROLLER -setcookie $COOKIE \
$ERL $ERL_OPTS $ERL_RSH -noshell $PROTO_DIST $NAMETYPE $CONTROLLER$CONTROLLER_EXTENDS -setcookie $COOKIE \
+P $MAX_PROCESS \
-kernel inet_dist_listen_min $ERL_DIST_PORTS_MIN -kernel inet_dist_listen_max $ERL_DIST_PORTS_MAX \
-s tsung_controller \
Expand All @@ -91,7 +92,7 @@ start() {
}

debug() {
$ERL $ERL_OPTS $ERL_RSH $NAMETYPE $CONTROLLER $PROTO_DIST -setcookie $COOKIE \
$ERL $ERL_OPTS $ERL_RSH $NAMETYPE $CONTROLLER$CONTROLLER_EXTENDS $PROTO_DIST -setcookie $COOKIE \
+P $MAX_PROCESS \
-kernel inet_dist_listen_min $ERL_DIST_PORTS_MIN -kernel inet_dist_listen_max $ERL_DIST_PORTS_MAX \
-s tsung_controller \
Expand Down Expand Up @@ -164,7 +165,7 @@ usage() {
echo " -X <dir> add additional erlang load paths (multiple -X arguments allowed)"
echo " -m <file> write monitoring output on this file (default is tsung.log)"
echo " (use - for standard output)"
echo " -F use long names (FQDN) for erlang nodes"
echo " -F <ip> use long names (FQDN) for erlang nodes; you can assign local bind available IP (not assign? default is the host's name)"
echo " -L <lifetime> SSL session lifetime (600sec by default)"
echo " -w <delay> warmup delay (default is 1 sec)"
echo " -n disable web GUI (started by default on port 8091)"
Expand All @@ -178,7 +179,7 @@ usage() {
exit
}

while getopts "6vhknf:l:d:r:i:Fsw:m:p:x:X:t:T:" Option
while getopts "6vhknf:l:d:r:i:F:sw:m:p:x:X:t:T:" Option
do
case $Option in
f) CONF_OPT_FILE=$OPTARG;;
Expand All @@ -201,7 +202,12 @@ do
X) EXTRA_LOAD_PATHS="$EXTRA_LOAD_PATHS -pa $OPTARG";;
r) ERL_RSH=" -rsh $OPTARG ";;
6) PROTO_DIST=" -proto_dist inet6_tcp ";;
F) NAMETYPE="-name";;
F) NAMETYPE="-name"
SERVER_IP=$OPTARG
if [ "$SERVER_IP" != "" ]; then
CONTROLLER_EXTENDS="@$SERVER_IP"
fi
;;
L) SSL_SESSION_LIFETIME=$OPTARG;;
w) WARM_TIME=$OPTARG;;
t) ERL_DIST_PORTS_MIN=$OPTARG;;
Expand Down

0 comments on commit cdde130

Please sign in to comment.