diff --git a/bin/as.sh b/bin/as.sh index 490bfcf65..ba1a08c5b 100755 --- a/bin/as.sh +++ b/bin/as.sh @@ -128,6 +128,11 @@ COMMAND= # batch file to execute BATCH_FILE= +# tunnel server url +TUNNEL_SERVER= +# agent id +AGENT_ID= + ############ Command Arguments ############ # if arguments contains -c/--command or -f/--batch-file, BATCH_MODE will be true @@ -395,6 +400,7 @@ usage() Usage: $0 [-h] [--target-ip ] [--telnet-port ] [--http-port ] [--session-timeout ] [--arthas-home ] + [--tunnel-server ] [--agent-id ] [--use-version ] [--repo-mirror ] [--versions] [--use-http] [--attach-only] [-c ] [-f ] [-v] [pid] @@ -412,6 +418,8 @@ Options and Arguments: --use-http Enforce use http to download, default use https --attach-only Attach target process only, do not connect --debug-attach Debug attach agent + --tunnel-server Remote tunnel server url + --agent-id Special agent id -c,--command Command to execute, multiple commands separated by ; -f,--batch-file The batch file to execute @@ -424,6 +432,8 @@ EXAMPLES: ./as.sh ./as.sh --target-ip 0.0.0.0 ./as.sh --telnet-port 9999 --http-port -1 + ./as.sh --tunnel-server 'ws://192.168.10.11:7777/ws' + ./as.sh --tunnel-server 'ws://192.168.10.11:7777/ws' --agent-id bvDOe8XbTM2pQWjF4cfw ./as.sh -c 'sysprop; thread' ./as.sh -f batch.as ./as.sh --use-version 3.1.1 @@ -519,6 +529,16 @@ parse_arguments() shift # past argument shift # past value ;; + --tunnel-server) + TUNNEL_SERVER="$2" + shift # past argument + shift # past value + ;; + --agent-id) + AGENT_ID="$2" + shift # past argument + shift # past value + ;; --use-http) USE_HTTP=true shift # past argument @@ -685,6 +705,16 @@ attach_jvm() java_command+=("${BOOT_CLASSPATH}") fi + local tempArgs=() + if [ "${TUNNEL_SERVER}" ]; then + tempArgs+=("-tunnel-server") + tempArgs+=("${TUNNEL_SERVER}") + fi + if [ "${AGENT_ID}" ]; then + tempArgs+=("-agent-id") + tempArgs+=("${AGENT_ID}") + fi + "${java_command[@]}" \ ${ARTHAS_OPTS} ${JVM_OPTS} \ -jar "${arthas_lib_dir}/arthas-core.jar" \ @@ -693,6 +723,7 @@ attach_jvm() -telnet-port ${TELNET_PORT} \ -http-port ${HTTP_PORT} \ -session-timeout ${SESSION_TIMEOUT} \ + "${tempArgs[@]}" \ -core "${arthas_lib_dir}/arthas-core.jar" \ -agent "${arthas_lib_dir}/arthas-agent.jar"