Remove unused script. Fix #62

pull/66/merge
Huxing Zhang 6 years ago committed by GitHub
commit 9d91350bbe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -413,7 +413,6 @@ active_console()
local arthas_version=$1
local arthas_lib_dir=${ARTHAS_LIB_DIR}/${arthas_version}/arthas
if [[ "${arthas_version}" > "3.0" ]]; then
if [ "${BATCH_MODE}" = "true" ]; then
${JAVA_HOME}/bin/java ${ARTHAS_OPTS} ${JVM_OPTS} \
-jar ${arthas_lib_dir}/arthas-client.jar \
@ -427,21 +426,6 @@ active_console()
echo "'telnet' is required." 1>&2
return 1
fi
else
# for compatibility
# use default console
ARGS="${TARGET_IP} ${TELNET_PORT}"
if [ ${BATCH_MODE} = true ]; then
ARGS="$ARGS -b"
fi
if [ ! -z ${BATCH_SCRIPT} ]; then
ARGS="$ARGS -f $BATCH_SCRIPT"
fi
eval ${JAVA_HOME}/bin/java ${ARTHAS_OPTS} \
-cp ${arthas_lib_dir}/arthas-core.jar \
com.taobao.arthas.core.ArthasConsole \
${ARGS}
fi
}
# the main

@ -0,0 +1,79 @@
import com.taobao.arthas.core.Arthas;
import sun.management.VMManagement;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
/**
*
* @author BlueT
* 2018/9/17 23:34
*/
public class LocalDebugTest {
/**
* ./mvnw clean package -DskipTestszip packaging/target/
* debug
*
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
final int pid = getCurrentJVMPid();
System.out.println("pid:"+pid);
String path = LocalDebugTest.class.getResource("/").getPath();
final String npath = path.substring(1, path.indexOf("core")) + "packaging/target/";
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
Arthas.main(new String[]{
"-jar",
npath + "arthas-core.jar",
"-pid",
pid + "",
"-target-ip",
"127.0.0.1",
//"-telnet-port",
//"3658",
//"-http-port",
//"8563",
"-core",
npath + "arthas-core.jar",
"-agent",
npath + "arthas-agent.jar"
});
}
});
thread.start();
thread.join();
System.out.println("代码植入成功");
Thread.sleep(10000000);
}
private static int getCurrentJVMPid() {
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
try {
Field jvm = runtime.getClass().getDeclaredField("jvm");
jvm.setAccessible(true);
VMManagement mgmt = (VMManagement) jvm.get(runtime);
Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
pid_method.setAccessible(true);
return (int) (Integer) pid_method.invoke(mgmt);
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
throw new RuntimeException("Wow!");
}
}
Loading…
Cancel
Save