mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
57914: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3) 57901: Merged V4.1-BUG-FIX (4.1.8) to V4.2-BUG-FIX (4.2.1) 57891: MNT-9559: Merged DEV to V4.1-BUG-FIX 56210: MNT-9559: JMX Dump does not report Linux distribution - In JmxDumpUtil class was added updateOSNameAttributeForLinux(String) method; - Was added JmxDumpUtilTest test. 56250: MNT-9559: JMX Dump does not report Linux distribution 56340: MNT-9559: JMX Dump does not report Linux distribution git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61907 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -25,6 +25,7 @@ import java.text.DateFormat;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.TreeMap;
|
import java.util.TreeMap;
|
||||||
@@ -37,6 +38,9 @@ import javax.management.MBeanServerConnection;
|
|||||||
import javax.management.ObjectName;
|
import javax.management.ObjectName;
|
||||||
import javax.management.openmbean.CompositeData;
|
import javax.management.openmbean.CompositeData;
|
||||||
|
|
||||||
|
import org.alfresco.util.exec.RuntimeExec;
|
||||||
|
import org.alfresco.util.exec.RuntimeExec.ExecutionResult;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A utility class providing a method to dump a local or remote MBeanServer's entire object tree for support purposes.
|
* A utility class providing a method to dump a local or remote MBeanServer's entire object tree for support purposes.
|
||||||
@@ -58,6 +62,8 @@ public class JmxDumpUtil
|
|||||||
/** Place holder for unreadable values. */
|
/** Place holder for unreadable values. */
|
||||||
private static final String UNREADABLE_VALUE = "<not readable>";
|
private static final String UNREADABLE_VALUE = "<not readable>";
|
||||||
|
|
||||||
|
private static final String OS_NAME = "os.name";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dumps a local or remote MBeanServer's entire object tree for support purposes. Nested arrays and CompositeData
|
* Dumps a local or remote MBeanServer's entire object tree for support purposes. Nested arrays and CompositeData
|
||||||
* objects in MBean attribute values are handled.
|
* objects in MBean attribute values are handled.
|
||||||
@@ -143,9 +149,51 @@ public class JmxDumpUtil
|
|||||||
}
|
}
|
||||||
attributes.put(element.getName(), value);
|
attributes.put(element.getName(), value);
|
||||||
}
|
}
|
||||||
|
if (objectName.getCanonicalName().equals("Alfresco:Name=SystemProperties"))
|
||||||
|
{
|
||||||
|
String osName = (String) attributes.get(OS_NAME);
|
||||||
|
if (osName != null && osName.toLowerCase().startsWith("linux"))
|
||||||
|
{
|
||||||
|
attributes.put(OS_NAME, updateOSNameAttributeForLinux(osName));
|
||||||
|
}
|
||||||
|
}
|
||||||
tabulate(JmxDumpUtil.NAME_HEADER, JmxDumpUtil.VALUE_HEADER, attributes, out, 0);
|
tabulate(JmxDumpUtil.NAME_HEADER, JmxDumpUtil.VALUE_HEADER, attributes, out, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a Linux version
|
||||||
|
*
|
||||||
|
* @param osName os.name attribute
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String updateOSNameAttributeForLinux(String osName)
|
||||||
|
{
|
||||||
|
RuntimeExec exec = new RuntimeExec();
|
||||||
|
Map<String, String[]> commandMap = new HashMap<String, String[]>(3, 1.0f);
|
||||||
|
commandMap.put("Linux", new String[] { "lsb_release", "-d" });
|
||||||
|
exec.setCommandsAndArguments(commandMap);
|
||||||
|
ExecutionResult ret = exec.execute();
|
||||||
|
if (ret.getSuccess())
|
||||||
|
{
|
||||||
|
osName += " (" + ret.getStdOut().replace("\n", "") + ")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
commandMap.put("Linux", new String[] { "uname", "-a" });
|
||||||
|
exec.setCommandsAndArguments(commandMap);
|
||||||
|
ret = exec.execute();
|
||||||
|
if (ret.getSuccess())
|
||||||
|
{
|
||||||
|
osName += " (" + ret.getStdOut().replace("\n", "") + ")";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
osName += " (Unknown)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return osName;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dumps the details of a single CompositeData object.
|
* Dumps the details of a single CompositeData object.
|
||||||
*
|
*
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
package org.alfresco.repo.management;
|
||||||
|
|
||||||
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.alfresco.repo.security.authentication.AuthenticationComponent;
|
||||||
|
import org.alfresco.util.ApplicationContextHelper;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
|
|
||||||
|
public class JmxDumpUtilTest extends TestCase
|
||||||
|
{
|
||||||
|
|
||||||
|
private static ApplicationContext ctx = ApplicationContextHelper.getApplicationContext();
|
||||||
|
|
||||||
|
private AuthenticationComponent authenticationComponent;
|
||||||
|
|
||||||
|
public void testUpdateOSNameAttribute() throws Exception
|
||||||
|
{
|
||||||
|
String osName = System.getProperty("os.name");
|
||||||
|
if (osName.toLowerCase().startsWith("linux"))
|
||||||
|
{
|
||||||
|
String attr = JmxDumpUtil.updateOSNameAttributeForLinux(osName);
|
||||||
|
assertTrue(attr.toLowerCase().startsWith("linux ("));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user