smiklosovic commented on code in PR #3420:
URL: https://github.com/apache/cassandra/pull/3420#discussion_r1681456271
##########
src/java/org/apache/cassandra/tools/nodetool/GcStats.java:
##########
@@ -31,7 +38,55 @@ public void execute(NodeProbe probe)
double[] stats = probe.getAndResetGCStats();
double mean = stats[2] / stats[5];
double stdev = Math.sqrt((stats[3] / stats[5]) - (mean * mean));
+
+ OperatingSystemMXBean osBean = (OperatingSystemMXBean)
ManagementFactory.getOperatingSystemMXBean();
+
+ String freeMemoryBytes =
FBUtilities.prettyPrintMemory(osBean.getFreeMemorySize(), " ");
+ String totalMemoryBytes =
FBUtilities.prettyPrintMemory(osBean.getTotalMemorySize(), " ");
+ String totalswapMemoryBytes =
FBUtilities.prettyPrintMemory(osBean.getTotalSwapSpaceSize(), " ");
+
+ String OSInUseMemoryBytes =
FBUtilities.prettyPrintMemory(osBean.getTotalMemorySize() -
osBean.getFreeMemorySize(), " ");
+ String SWAPInUseMemoryBytes =
FBUtilities.prettyPrintMemory(osBean.getTotalSwapSpaceSize() -
osBean.getFreeSwapSpaceSize(), " ");
+
+ probe.output().out.println("GC Threads: " +
probe.getNumberOfGCThreads());
+ probe.output().out.println("Duration: " + probe.getYoungGenDuration()
+ " ms");
+ probe.output().out.println("MemLock: " +
NativeLibrary.jnaMemoryLockable() + "\n");
+
+ long osMemoryInUse = osBean.getTotalMemorySize() -
osBean.getFreeMemorySize();
+ double ospercent = ((double)osMemoryInUse/osBean.getTotalMemorySize())
* 100;
+ probe.output().out.println("OS Free Memory Bytes: " + freeMemoryBytes);
+ probe.output().out.println("OS Total Memory Bytes: " +
totalMemoryBytes);
+ probe.output().out.println("OS In Use: " + OSInUseMemoryBytes + " / "
+ totalMemoryBytes + " (" + String.format("%.1f", ospercent) + "%)\n");
+
+ long swapInUse;
+ double swapPercent;
+
+ if(osBean.getTotalSwapSpaceSize() == 0){
+ swapInUse = 0;
+ swapPercent = 0;
+ }
+ else{
+ swapInUse = osBean.getTotalSwapSpaceSize() -
osBean.getFreeSwapSpaceSize();
+ swapPercent = ((double)swapInUse/osBean.getTotalSwapSpaceSize()) *
100;
+ }
+
+ probe.output().out.println("Swap in Use: " + SWAPInUseMemoryBytes + "
/ " + totalswapMemoryBytes + " (" + String.format("%.1f", swapPercent) +
"%)\n");
probe.output().out.printf("%20s%20s%20s%20s%20s%20s%25s%n", "Interval
(ms)", "Max GC Elapsed (ms)", "Total GC Elapsed (ms)", "Stdev GC Elapsed (ms)",
"GC Reclaimed (MB)", "Collections", "Direct Memory Bytes");
-
probe.output().out.printf("%20.0f%20.0f%20.0f%20.0f%20.0f%20.0f%25d%n",
stats[0], stats[1], stats[2], stdev, stats[4], stats[5], (long)stats[6]);
+
probe.output().out.printf("%20.0f%20.0f%20.0f%20.0f%20.0f%20.0f%25d%n",
stats[0], stats[1], stats[2], stdev, stats[4], stats[5], -1);
+ MemoryUsage heapMemoryUsage = probe.getHeapMemoryUsage();
+
+ probe.output().out.print("\nHeap memory used: " +
FBUtilities.prettyPrintMemory(heapMemoryUsage.getUsed(), " "));
+ probe.output().out.println(" (" + String.format("%.1f",
((double)heapMemoryUsage.getUsed()/(double)heapMemoryUsage.getCommitted())*100)
+ "%)");
+
+ for (MemoryPoolMXBean memoryPoolMXBean :
ManagementFactory.getMemoryPoolMXBeans()) {
Review Comment:
@dhanush427 do you understand that when you do
`ManagementFactory.getMemoryPoolMXBeans`, then what you get is
`MemoryPoolMXBean` for the very JVM the nodetool commands was executed in?
The invocation of `nodetool` starts a JVM. Cassandra runs remotely, probably
on a completely different machine, in a completely different JVM.
So what you are printing here is statistics for a JVM nodetool was executed
in, you are not printing statistics for remote JVM Cassandra runs in.
As I mentioned, you need to use NodeProbe for that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]