[Jrisk-cvs] SF.net SVN: jrisk-code:[1049] Grasshopper
Brought to you by:
yuranet
|
From: <yu...@us...> - 2024-06-02 12:15:33
|
Revision: 1049
http://sourceforge.net/p/jrisk/code/1049
Author: yuranet
Date: 2024-06-02 12:15:31 +0000 (Sun, 02 Jun 2024)
Log Message:
-----------
more info
Modified Paths:
--------------
Grasshopper/ChangeLog.txt
Grasshopper/src/net/yura/grasshopper/BugSystemInfo.java
Modified: Grasshopper/ChangeLog.txt
===================================================================
--- Grasshopper/ChangeLog.txt 2024-05-24 18:23:39 UTC (rev 1048)
+++ Grasshopper/ChangeLog.txt 2024-06-02 12:15:31 UTC (rev 1049)
@@ -2,6 +2,8 @@
2.14
sound card info
+ memory info
+ command line info
2.13
Modified: Grasshopper/src/net/yura/grasshopper/BugSystemInfo.java
===================================================================
--- Grasshopper/src/net/yura/grasshopper/BugSystemInfo.java 2024-05-24 18:23:39 UTC (rev 1048)
+++ Grasshopper/src/net/yura/grasshopper/BugSystemInfo.java 2024-06-02 12:15:31 UTC (rev 1049)
@@ -3,7 +3,9 @@
import java.io.File;
import java.util.Date;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
+import java.util.Optional;
import java.util.Properties;
/**
@@ -15,7 +17,7 @@
public static Map addSystemInfo() {
- String systemLocale,localhost,systemProperties,environment,lookandfeel,installDate;
+ String systemLocale,localhost,systemProperties,environment,lookandfeel,installDate,memoryInfo,commandLine;
try {
systemLocale = java.util.Locale.getDefault().toString();
@@ -75,7 +77,46 @@
catch (Throwable e) {
installDate = e.toString();
}
+
+ try {
+ Runtime rt = Runtime.getRuntime();
+ StringBuffer sb = new StringBuffer();
+ final int mb = 1024 * 1024;
+ sb.append("Free memory (MB): ");
+ sb.append(rt.freeMemory() / mb);
+ sb.append("\nTotal memory (MB): ");
+ sb.append(rt.totalMemory() / mb);
+ sb.append("\nMax memory (MB): ");
+ sb.append(rt.maxMemory() / mb);
+
+ memoryInfo = sb.toString();
+ }
+ catch (Throwable e) {
+ memoryInfo = e.toString();
+ }
+
+ try {
+ try {
+ // java.lang.ProcessHandle.current().info().commandLine();
+ Class phClass = Class.forName("java.lang.ProcessHandle");
+ Object phInfo = phClass.getMethod("info").invoke(phClass.getMethod("current").invoke(null));
+ Optional<String> myCommandLine = (Optional<String>)Class.forName("java.lang.ProcessHandle$Info").getMethod("commandLine").invoke(phInfo);
+
+ if (!myCommandLine.isPresent()) {
+ throw new Exception("not present");
+ }
+ commandLine = myCommandLine.get();
+ }
+ catch (Throwable th) {
+ List<String> args = java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments();
+ commandLine = args.toString();
+ }
+ }
+ catch(Throwable th) {
+ commandLine = th.toString();
+ }
+
Map map = new java.util.Hashtable();
map.put("systemLocale",systemLocale);
map.put("localhost",localhost);
@@ -83,12 +124,11 @@
map.put("environment",environment);
map.put("lookandfeel",lookandfeel);
map.put("installDate",installDate);
+ map.put("memoryInfo", memoryInfo);
+ map.put("commandLine", commandLine);
map.put("submitDate",new java.util.Date().toString());
return map;
-
}
-
-
}
|