add tutorials link

pull/525/head
hengyunabc 6 years ago
parent 813ab9304e
commit c390d5571b

@ -3,7 +3,6 @@ package com.taobao.arthas.boot;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.lang.management.ManagementFactory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -18,6 +17,7 @@ import com.taobao.arthas.common.AnsiLog;
import com.taobao.arthas.common.ExecutingCommand;
import com.taobao.arthas.common.IOUtils;
import com.taobao.arthas.common.JavaVersionUtils;
import com.taobao.arthas.common.PidUtils;
/**
*
@ -25,27 +25,8 @@ import com.taobao.arthas.common.JavaVersionUtils;
*
*/
public class ProcessUtils {
private static String PID = "-1";
private static String FOUND_JAVA_HOME = null;
static {
// https://stackoverflow.com/a/7690178
String jvmName = ManagementFactory.getRuntimeMXBean().getName();
int index = jvmName.indexOf('@');
if (index > 0) {
try {
PID = Long.toString(Long.parseLong(jvmName.substring(0, index)));
} catch (Throwable e) {
// ignore
}
}
}
public static String getPid() {
return PID;
}
@SuppressWarnings("resource")
public static int select(boolean v, int telnetPortPid) throws InputMismatchException {
Map<Integer, String> processMap = listProcessByJps(v);
@ -120,7 +101,7 @@ public class ProcessUtils {
List<String> lines = ExecutingCommand.runNative(command);
int currentPid = Integer.parseInt(ProcessUtils.getPid());
int currentPid = Integer.parseInt(PidUtils.getPid());
for (String line : lines) {
String[] strings = line.trim().split("\\s+");
if (strings.length < 1) {

@ -0,0 +1,30 @@
package com.taobao.arthas.common;
import java.lang.management.ManagementFactory;
/**
*
* @author hengyunabc 2019-02-16
*
*/
public class PidUtils {
private static String PID = "-1";
static {
// https://stackoverflow.com/a/7690178
String jvmName = ManagementFactory.getRuntimeMXBean().getName();
int index = jvmName.indexOf('@');
if (index > 0) {
try {
PID = Long.toString(Long.parseLong(jvmName.substring(0, index)));
} catch (Throwable e) {
// ignore
}
}
}
public static String currentPid() {
return PID;
}
}

@ -20,7 +20,6 @@ import com.taobao.arthas.core.shell.system.impl.InternalCommandManager;
import com.taobao.arthas.core.shell.system.impl.JobControllerImpl;
import com.taobao.arthas.core.shell.term.Term;
import com.taobao.arthas.core.util.Constants;
import com.taobao.arthas.core.util.DateUtils;
import com.taobao.arthas.core.util.LogUtil;
import com.taobao.middleware.logger.Logger;
@ -114,8 +113,6 @@ public class ShellImpl implements Shell {
if (welcome != null && welcome.length() > 0) {
term.write(welcome + "\n");
term.write("pid: " + session.get(Session.PID) + "\n");
term.write("time: " + DateUtils.getCurrentDate() + "\n\n");
}
return this;
}

@ -1,5 +1,6 @@
package com.taobao.arthas.core.util;
import com.taobao.arthas.common.PidUtils;
import com.taobao.arthas.core.shell.ShellServerOptions;
import com.taobao.middleware.logger.Logger;
import com.taobao.text.Color;
@ -19,6 +20,7 @@ public class ArthasBanner {
private static final String CREDIT_LOCATION = "/com/taobao/arthas/core/res/thanks.txt";
private static final String VERSION_LOCATION = "/com/taobao/arthas/core/res/version";
private static final String WIKI = "https://alibaba.github.io/arthas";
private static final String TUTORIALS = "https://alibaba.github.io/arthas/arthas-tutorials";
private static String LOGO = "Welcome to Arthas";
private static String VERSION = "unknown";
@ -70,6 +72,10 @@ public class ArthasBanner {
return WIKI;
}
public static String tutorials() {
return TUTORIALS;
}
public static String credit() {
return THANKS;
}
@ -88,6 +94,13 @@ public class ArthasBanner {
public static String welcome() {
logger.info("arthas version: " + version());
return logo() + "\n" + "wiki: " + wiki() + "\n" + "version: " + version();
TableElement table = new TableElement().rightCellPadding(1)
.row("wiki", wiki())
.row("tutorials", tutorials())
.row("version", version())
.row("pid", PidUtils.currentPid())
.row("time", DateUtils.getCurrentDate());
return logo() + "\n" + RenderUtil.render(table);
}
}

Loading…
Cancel
Save