From ad1eb20e20aa7594bff9fc3a27a9201958019f0c Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Sun, 27 Oct 2019 19:53:43 +0800 Subject: [PATCH] IDEMPIERE-4072 iDempiere Monitor: Implement server and cache details for cluster node. Show propertyFileName, Average GC time and host name. --- .../org/compiere/server/SystemInfo.java | 29 +++++++++--- .../org/compiere/web/AdempiereMonitor.java | 46 ++++++++----------- 2 files changed, 41 insertions(+), 34 deletions(-) diff --git a/org.adempiere.server/src/main/server/org/compiere/server/SystemInfo.java b/org.adempiere.server/src/main/server/org/compiere/server/SystemInfo.java index 8192c8537a..7517bd0bf1 100644 --- a/org.adempiere.server/src/main/server/org/compiere/server/SystemInfo.java +++ b/org.adempiere.server/src/main/server/org/compiere/server/SystemInfo.java @@ -37,11 +37,13 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.logging.Level; +import org.compiere.Adempiere; import org.compiere.db.AdempiereDatabase; import org.compiere.db.CConnection; import org.compiere.model.MSession; import org.compiere.util.CLogMgt; import org.compiere.util.CMemoryUsage; +import org.compiere.util.Ini; import org.idempiere.distributed.IClusterMember; import org.idempiere.distributed.IClusterService; import org.idempiere.server.cluster.ClusterServerMgr; @@ -58,6 +60,8 @@ public class SystemInfo implements Serializable { */ private static final long serialVersionUID = -4451616690416295597L; + private String propertyFileName; + private String idempereHome; private String operatingSystem; private String javaVM; private String databaseDescription; @@ -90,6 +94,22 @@ public class SystemInfo implements Serializable { private SystemInfo() { } + /** + * + * @return idempiere property filename + */ + public String getPropertyFileName() { + return propertyFileName; + } + + /** + * + * @return idempiere home + */ + public String getIDempiereHome() { + return idempereHome; + } + /** * @return the operatingSystem */ @@ -218,6 +238,8 @@ public class SystemInfo implements Serializable { public static SystemInfo getLocalSystemInfo() { SystemInfo si = new SystemInfo(); + si.propertyFileName = Ini.getPropertyFileName(); + si.idempereHome = Adempiere.getAdempiereHome(); OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean(); String osInfo = os.getName() + " " + os.getVersion(); osInfo += " (" + os.getArch() + ")"; @@ -259,13 +281,6 @@ public class SystemInfo implements Serializable { return si; } - /** - * @return the serialversionuid - */ - public static long getSerialversionuid() { - return serialVersionUID; - } - /** * @return the garbageCollectionCount */ diff --git a/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java b/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java index 2f06f4210d..1b13cea2b7 100644 --- a/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java +++ b/org.adempiere.server/src/main/servlet/org/compiere/web/AdempiereMonitor.java @@ -707,13 +707,9 @@ public class AdempiereMonitor extends HttpServlet p para = new p(); StringBuilder nodeBuilder = new StringBuilder(local.getId()); InetAddress address = local.getAddress(); - String ip = address != null ? address.getHostAddress() : null; - if (ip != null && - (ip.startsWith("10.") || - ip.startsWith("172.16") || - ip.startsWith("192.168"))) + if (address != null) { - nodeBuilder.append(" (").append(ip).append(")"); + nodeBuilder.append(" (").append(address.getCanonicalHostName()).append(")"); } para.addElement(nodeBuilder.toString()); @@ -728,13 +724,9 @@ public class AdempiereMonitor extends HttpServlet para.addElement(" - "); nodeBuilder = new StringBuilder(member.getId()); address = member.getAddress(); - ip = address != null ? address.getHostAddress() : null; - if (ip != null && - (ip.startsWith("10.") || - ip.startsWith("172.16") || - ip.startsWith("192.168"))) + if (address != null) { - nodeBuilder.append(" (").append(ip).append(")"); + nodeBuilder.append(" (").append(address.getCanonicalHostName()).append(")"); } a link = new a ("idempiereMonitor?NodeInfo="+member.getId(), nodeBuilder.toString()); para.addElement(link); @@ -1028,7 +1020,7 @@ public class AdempiereMonitor extends HttpServlet SystemInfo systemInfo = SystemInfo.getLocalSystemInfo(); tr line = new tr(); line.addElement(new th().addElement(Adempiere.getURL())); - line.addElement(new td().addElement(Adempiere.getAdempiereHome())); + line.addElement(new td().addElement(systemInfo.getPropertyFileName())); table.addElement(line); // OS + Name line = new tr(); @@ -1041,7 +1033,7 @@ public class AdempiereMonitor extends HttpServlet // Java + email line = new tr(); line.addElement(new th().addElement(systemInfo.getJavaVM())); - line.addElement(new td().addElement(system.getSupportEMail())); + line.addElement(new td().addElement("Average GC Time=" + systemInfo.getGarbageCollectionTime() / systemInfo.getGarbageCollectionCount() + " ms")); table.addElement(line); // DB + Instance line = new tr(); @@ -1533,26 +1525,26 @@ public class AdempiereMonitor extends HttpServlet table.setCellSpacing(2); table.setCellPadding(2); + tr line = new tr(); + line.addElement(new th().addElement("Property File")); + line.addElement(new td().addElement(systemInfo.getPropertyFileName())); + table.addElement(line); + + line = new tr(); InetAddress address = systemInfo.getAddress(); - String ip = address != null ? address.getHostAddress() : null; - if (ip != null && - (ip.startsWith("10.") || - ip.startsWith("172.16") || - ip.startsWith("192.168"))) - { - tr line = new tr(); - line.addElement(new th().addElement("IP Address")); - line.addElement(new td().addElement(ip)); - table.addElement(line); - } + line.addElement(new th().addElement("Host Name")); + line.addElement(new td().addElement(address.getCanonicalHostName())); + table.addElement(line); // OS + Name - tr line = new tr(); - line.addElement(new th().addElement(systemInfo.getOperatingSystem())); + line = new tr(); + line.addElement(new th().addElement("Operating System")); + line.addElement(new td().addElement(systemInfo.getOperatingSystem())); table.addElement(line); // Java + email line = new tr(); line.addElement(new th().addElement(systemInfo.getJavaVM())); + line.addElement(new td().addElement("Average GC Time=" + systemInfo.getGarbageCollectionTime() / systemInfo.getGarbageCollectionCount() + " ms")); table.addElement(line); // DB + Instance line = new tr();