diff --git a/src/main/assembly/distribution.xml b/src/main/assembly/distribution.xml
index 2d2765b..5f85366 100644
--- a/src/main/assembly/distribution.xml
+++ b/src/main/assembly/distribution.xml
@@ -4,12 +4,21 @@
distribution
tar.gz
+ zip
/
+
+
+ /
+
+
+
+ /
+
/
diff --git a/src/main/java/com/jvmtop/JvmTop.java b/src/main/java/com/jvmtop/JvmTop.java
index dd4165c..8b4b201 100644
--- a/src/main/java/com/jvmtop/JvmTop.java
+++ b/src/main/java/com/jvmtop/JvmTop.java
@@ -57,7 +57,7 @@
public class JvmTop
{
- public static final String VERSION = "0.8.0 alpha";
+ public static final String VERSION = "0.9.1 beta";
private Double delay_ = 1.0;
@@ -112,6 +112,12 @@ private static OptionParser createOptionParser()
"sets displayed thread name length in detail mode (defaults to 30)")
.withRequiredArg().ofType(Integer.class);
+ parser
+ .acceptsAll(Arrays.asList(new String[] { "s", "threadsearch" }),
+ "search string in showed fields")
+ .withRequiredArg().ofType(String.class);
+
+
return parser;
}
@@ -149,6 +155,8 @@ public static void main(String[] args) throws Exception
boolean threadLimitEnabled = true;
Integer threadNameWidth = null;
+
+ String threadNameSearch = null;
if (a.hasArgument("delay"))
{
@@ -202,6 +210,11 @@ public static void main(String[] args) throws Exception
threadNameWidth = (Integer) a.valueOf("threadnamewidth");
}
+ if (a.hasArgument("threadsearch"))
+ {
+ threadNameSearch = (String) a.valueOf("threadsearch");
+ }
+
if (sysInfoOption)
{
outputSystemProps();
@@ -233,6 +246,10 @@ public static void main(String[] args) throws Exception
{
vmDetailView.setThreadNameDisplayWidth(threadNameWidth);
}
+ if (threadNameSearch != null)
+ {
+ vmDetailView.setThreadSearch(threadNameSearch);
+ }
jvmTop.run(vmDetailView);
}
@@ -330,9 +347,8 @@ private void clearTerminal()
{
if (System.getProperty("os.name").contains("Windows"))
{
- //hack
- System.out
- .printf("%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n%n");
+ System.out.print("\033[H\033[2J");
+ System.out.flush();
}
else if (System.getProperty("jvmtop.altClear") != null)
{
diff --git a/src/main/java/com/jvmtop/view/AbstractConsoleView.java b/src/main/java/com/jvmtop/view/AbstractConsoleView.java
index 6f4de12..6bac6cb 100644
--- a/src/main/java/com/jvmtop/view/AbstractConsoleView.java
+++ b/src/main/java/com/jvmtop/view/AbstractConsoleView.java
@@ -88,7 +88,7 @@ public String toHHMM(long millis)
StringBuilder sb = new StringBuilder();
Formatter formatter = new Formatter(sb);
formatter
-.format("%2d:%2dm", millis / 1000 / 3600,
+.format("%02d:%02dm", millis / 1000 / 3600,
(millis / 1000 / 60) % 60);
return sb.toString();
}
diff --git a/src/main/java/com/jvmtop/view/VMDetailView.java b/src/main/java/com/jvmtop/view/VMDetailView.java
index 21a40f0..6491b6a 100644
--- a/src/main/java/com/jvmtop/view/VMDetailView.java
+++ b/src/main/java/com/jvmtop/view/VMDetailView.java
@@ -46,12 +46,13 @@ public class VMDetailView extends AbstractConsoleView
private boolean sortByTotalCPU_ = false;
- private int numberOfDisplayedThreads_ = 10;
+ private int numberOfDisplayedThreads_ = 100;
- private int threadNameDisplayWidth_ = 30;
+ private int threadNameDisplayWidth_ = 65;
- private boolean displayedThreadLimit_ = true;
+ private boolean displayedThreadLimit_ = false;
+ private String threadSearch = null;
//TODO: refactor
private Map previousThreadCPUMillis = new HashMap();
@@ -120,15 +121,15 @@ public void printView() throws Exception
System.out.printf(" ARGS: [UNKNOWN] %n");
}
- String join = join(vmInfo_.getRuntimeMXBean().getInputArguments(), " ");
- if (join.length() > 65)
- {
- System.out.printf(" VMARGS: %s[...]%n", leftStr(join, 65));
- }
- else
- {
- System.out.printf(" VMARGS: %s%n", join);
- }
+ String join = "\n " + join(vmInfo_.getRuntimeMXBean().getInputArguments(), "\n ");
+// if (join.length() > 65)
+// {
+// System.out.printf(" VMARGS: %s[...]%n", leftStr(join, 65));
+// }
+// else
+// {
+ System.out.printf(" VMARGS: %s%n", join);
+// }
System.out.printf(" VM: %s %s %s%n", properties.get("java.vendor"),
properties.get("java.vm.name"), properties.get("java.version"));
@@ -159,10 +160,11 @@ public void printView() throws Exception
/**
* @throws Exception
*/
+ @SuppressWarnings("unchecked")
private void printTopThreads() throws Exception
{
System.out.printf(" %6s %-" + threadNameDisplayWidth_
- + "s %13s %8s %8s %5s %n", "TID", "NAME", "STATE", "CPU",
+ + "s %-13s %-8s %-8s %-5s %n", "TID", "NAME", "STATE", "CPU",
"TOTALCPU", "BLOCKEDBY");
if (vmInfo_.getThreadMXBean().isThreadCpuTimeSupported())
@@ -173,19 +175,30 @@ private void printTopThreads() throws Exception
Map cpuTimeMap = new TreeMap();
+ String threadSearchLower = (threadSearch==null?null:threadSearch.toLowerCase());
for (Long tid : vmInfo_.getThreadMXBean().getAllThreadIds())
{
long threadCpuTime = vmInfo_.getThreadMXBean().getThreadCpuTime(tid);
+ ThreadInfo info = vmInfo_.getThreadMXBean().getThreadInfo(tid);
long deltaThreadCpuTime = 0;
if (previousThreadCPUMillis.containsKey(tid))
{
deltaThreadCpuTime = threadCpuTime - previousThreadCPUMillis.get(tid);
-
- cpuTimeMap.put(tid, deltaThreadCpuTime);
+ if (threadSearch != null && info != null) {
+ if (info.getThreadName().toLowerCase().contains(threadSearchLower)
+ ||(""+info.getThreadState()).toLowerCase().contains(threadSearchLower)
+ ||(tid.toString()).toLowerCase().contains(threadSearchLower))
+ {
+ cpuTimeMap.put(tid, deltaThreadCpuTime);
+ }
+ }
+ else
+ {
+ cpuTimeMap.put(tid, deltaThreadCpuTime);
+ }
}
newThreadCPUMillis.put(tid, threadCpuTime);
}
-
cpuTimeMap = sortByValue(cpuTimeMap, true);
int displayedThreads = 0;
@@ -202,15 +215,17 @@ private void printTopThreads() throws Exception
{
System.out.printf(
" %6d %-" + threadNameDisplayWidth_
- + "s %13s %5.2f%% %5.2f%% %5s %n",
+ + "s %-13s %5.2f%% %5.2f%% %5s %n",
tid,
leftStr(info.getThreadName(), threadNameDisplayWidth_),
info.getThreadState(),
getThreadCPUUtilization(cpuTimeMap.get(tid),
vmInfo_.getDeltaUptime()),
- getThreadCPUUtilization(vmInfo_.getThreadMXBean()
- .getThreadCpuTime(tid), vmInfo_.getProxyClient()
- .getProcessCpuTime(), 1), getBlockedThread(info));
+ getThreadCPUUtilization(
+ vmInfo_.getThreadMXBean().getThreadCpuTime(tid),
+ vmInfo_.getProxyClient().getProcessCpuTime(),
+ 1),
+ getBlockedThread(info));
}
}
if (newThreadCPUMillis.size() >= numberOfDisplayedThreads_
@@ -273,6 +288,17 @@ public void setThreadNameDisplayWidth(int threadNameDisplayWidth_)
this.threadNameDisplayWidth_ = threadNameDisplayWidth_;
}
+ public String getThreadSearch()
+ {
+ return threadSearch;
+ }
+
+ public void setThreadSearch(String threadSearch_)
+ {
+ this.threadSearch = threadSearch_;
+ }
+
+
private double getThreadCPUUtilization(long deltaThreadCpuTime, long totalTime)
{
return getThreadCPUUtilization(deltaThreadCpuTime, totalTime, 1000 * 1000);
diff --git a/src/main/java/com/jvmtop/view/VMOverviewView.java b/src/main/java/com/jvmtop/view/VMOverviewView.java
index 6f8d862..cda6e73 100644
--- a/src/main/java/com/jvmtop/view/VMOverviewView.java
+++ b/src/main/java/com/jvmtop/view/VMOverviewView.java
@@ -71,19 +71,19 @@ else if (vmInfo.getState() == VMInfoState.ATTACHED_UPDATE_ERROR)
{
System.out
.printf(
- "%5d %-15.15s [ERROR: Could not fetch telemetries (Process DEAD?)] %n",
+ "%5d %-25.25s [ERROR: Could not fetch telemetries (Process DEAD?)] %n",
vmInfo.getId(), getEntryPointClass(vmInfo.getDisplayName()));
}
else if (vmInfo.getState() == VMInfoState.ERROR_DURING_ATTACH)
{
- System.out.printf("%5d %-15.15s [ERROR: Could not attach to VM] %n",
+ System.out.printf("%5d %-25.25s [ERROR: Could not attach to VM] %n",
vmInfo.getId(), getEntryPointClass(vmInfo.getDisplayName()));
}
else if (vmInfo.getState() == VMInfoState.CONNECTION_REFUSED)
{
System.out.printf(
- "%5d %-15.15s [ERROR: Connection refused/access denied] %n",
+ "%5d %-25.25s [ERROR: Connection refused/access denied] %n",
vmInfo.getId(), getEntryPointClass(vmInfo.getDisplayName()));
}
@@ -121,7 +121,7 @@ private void printVM(VMInfo vmInfo) throws Exception
System.out
.printf(
- "%5d %-15.15s %5s %5s %5s %5s %5.2f%% %5.2f%% %-5.5s %8.8s %4d %2.2s%n",
+ "%5d %-25.25s %5s %5s %5s %5s %5.2f%% %5.2f%% %-5.5s %8.8s %4d %2.2s%n",
vmInfo.getId(), getEntryPointClass(vmInfo.getDisplayName()),
toMB(vmInfo.getHeapUsed()), toMB(vmInfo.getHeapMax()),
toMB(vmInfo.getNonHeapUsed()), toMB(vmInfo.getNonHeapMax()),
@@ -173,7 +173,7 @@ private void scanForNewVMs()
*/
private void printHeader()
{
- System.out.printf("%5s %-15.15s %5s %5s %5s %5s %6s %6s %5s %8s %4s %2s%n",
+ System.out.printf("%5s %-25.25s %5s %5s %5s %5s %6s %6s %5s %8s %4s %2s%n",
"PID", "MAIN-CLASS", "HPCUR", "HPMAX", "NHCUR", "NHMAX", "CPU", "GC",
"VM", "USERNAME", "#T", "DL");
}