code: public static String getMBeanAttribute(String name, String attrName) throws JMException
     {
        MBeanServer server = getMBeanServer();
        ObjectName objName = new ObjectName(name);
  
        String value = null;
        try
        {
           Object attr = server.getAttribute(objName, attrName);
           if (attr != null)
              value = attr.toString();
        }
        catch (JMException e)
        {
           value = e.getMessage();
        }
        return value;
     }
docs: Get MBean attribute
  @param name The bean name
  @param attrName The attribute name
  @return The data
  @exception JMException Thrown if an error occurs