dhanush427 commented on code in PR #3420:
URL: https://github.com/apache/cassandra/pull/3420#discussion_r1688015097


##########
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:
   very good point, I have updated to use NodeProbe to get the statistics for 
the remote JVM Cassandra runs in.



-- 
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]

Reply via email to