as.sh support tunnel server/agent id. #835

This commit is contained in:
hengyunabc
2019-08-30 11:12:02 +08:00
parent fe8c8d2ebc
commit f91ecd2bdb
+31
View File
@@ -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 <value>] [--telnet-port <value>]
[--http-port <value>] [--session-timeout <value>] [--arthas-home <value>]
[--tunnel-server <value>] [--agent-id <value>]
[--use-version <value>] [--repo-mirror <value>] [--versions] [--use-http]
[--attach-only] [-c <value>] [-f <value>] [-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 <value> Command to execute, multiple commands separated
by ;
-f,--batch-file <value> The batch file to execute
@@ -424,6 +432,8 @@ EXAMPLES:
./as.sh <pid>
./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' <pid>
./as.sh -f batch.as <pid>
./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"