echo"Target process $TARGET_PID is not the process using port $HTTP_PORT, you will connect to an unexpected process."
echo"Target process $TARGET_PID is not the process using port $(getHttpPortOrDefault), you will connect to an unexpected process."
echo"1. Try to restart as.sh, select process $httpPortPid, shutdown it first with running the 'stop' command."
echo"2. Try to use different http port, for example: as.sh --telnet-port 9998 --http-port 9999"
exit1
@ -759,14 +801,32 @@ attach_jvm()
tempArgs+=("${STAT_URL}")
fi
if["${APP_NAME}"];then
tempArgs+=("-app-name")
tempArgs+=("${APP_NAME}")
fi
if["${TARGET_IP}"];then
tempArgs+=("-target-ip")
tempArgs+=("${TARGET_IP}")
fi
if["${TELNET_PORT}"];then
tempArgs+=("-telnet-port")
tempArgs+=("${TELNET_PORT}")
fi
if["${HTTP_PORT}"];then
tempArgs+=("-http-port")
tempArgs+=("${HTTP_PORT}")
fi
if["${SESSION_TIMEOUT}"];then
tempArgs+=("-session-timeout")
tempArgs+=("${SESSION_TIMEOUT}")
fi
"${java_command[@]}"\
${ARTHAS_OPTS}${JVM_OPTS}\
-jar "${arthas_lib_dir}/arthas-core.jar"\
-pid ${TARGET_PID}\
-target-ip ${TARGET_IP}\
-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"
@ -811,7 +871,7 @@ sanity_check() {
}
port_pid_check(){
if[[$TELNET_PORT > 0]];then
if[[$(getTelnetPortOrDefault) > 0]];then
local telnet_output
local find_process_status
# declare local var before var=$()
@ -844,15 +904,15 @@ port_pid_check() {
}
print_telnet_port_pid_error(){
echo"[ERROR] The telnet port $TELNET_PORT is used by process $telnetPortPid instead of target process $TARGET_PID, you will connect to an unexpected process."
echo"[ERROR] The telnet port $(getTelnetPortOrDefault) is used by process $telnetPortPid instead of target process $TARGET_PID, you will connect to an unexpected process."
echo"[ERROR] 1. Try to restart as.sh, select process $telnetPortPid, shutdown it first with running the 'stop' command."
echo"[ERROR] 2. Try to stop the existing arthas instance: java -jar arthas-client.jar 127.0.0.1 $TELNET_PORT -c \"stop\""
echo"[ERROR] 2. Try to stop the existing arthas instance: java -jar arthas-client.jar 127.0.0.1 $(getTelnetPortOrDefault) -c \"stop\""
echo"[ERROR] 3. Try to use different telnet port, for example: as.sh --telnet-port 9998 --http-port -1"
}
print_telnet_port_used_error(){
localerror_msg=$1
echo"[ERROR] The telnet port $TELNET_PORT is used, but process $error_msg, you will connect to an unexpected process."
echo"[ERROR] The telnet port $(getTelnetPortOrDefault) is used, but process $error_msg, you will connect to an unexpected process."
echo"[ERROR] Try to use different telnet port, for example: as.sh --telnet-port 9998 --http-port -1"
}
@ -881,16 +941,16 @@ active_console()
if["${COMMAND}"];then
"${JAVA_HOME}/bin/java"${ARTHAS_OPTS}${JVM_OPTS}\
-jar "${arthas_lib_dir}/arthas-client.jar"\
${TARGET_IP}\
${TELNET_PORT}\
$(getTargetIPOrDefault)\
$(getTelnetPortOrDefault)\
"${tempArgs[@]}"\
-c "${COMMAND}"
fi
if["${BATCH_FILE}"];then
"${JAVA_HOME}/bin/java"${ARTHAS_OPTS}${JVM_OPTS}\
-jar "${arthas_lib_dir}/arthas-client.jar"\
${TARGET_IP}\
${TELNET_PORT}\
$(getTargetIPOrDefault)\
$(getTelnetPortOrDefault)\
"${tempArgs[@]}"\
-f ${BATCH_FILE}
fi
@ -899,12 +959,12 @@ active_console()
if[[$(command -v telnet)== *"system32"* ]];then
# Windows/system32/telnet.exe can not run in Cygwin/MinGw
echo"It seems that current bash is under Windows. $(command -v telnet) can not run under bash."
echo"Please start cmd.exe from Windows start menu, and then run telnet ${TARGET_IP}${TELNET_PORT} to connect to target process."
echo"Or visit http://127.0.0.1:${HTTP_PORT} to connect to target process."
echo"Please start cmd.exe from Windows start menu, and then run telnet $(getTargetIPOrDefault)$(getTelnetPortOrDefault) to connect to target process."
echo"Or visit http://127.0.0.1:$(getHttpPortOrDefault) to connect to target process."
return1
fi
echo"telnet connecting to arthas server... current timestamp is `date +%s`"