From: <gla...@hy...> - 2010-04-22 19:15:49
|
Author: glaullon Date: 2010-04-22 12:15:40 -0700 (Thu, 22 Apr 2010) New Revision: 14537 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14537 Modified: trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/WeblogicDetector.java trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/ApplicationQuery.java trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/DynamicServiceQuery.java trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicDiscover.java trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicQuery.java trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicRuntimeDiscoverer.java Log: [SUPPORT-7512] WebLogic 9.2.3 services not auto-discovered Modified: trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/WeblogicDetector.java =================================================================== --- trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/WeblogicDetector.java 2010-04-22 17:39:44 UTC (rev 14536) +++ trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/WeblogicDetector.java 2010-04-22 19:15:40 UTC (rev 14537) @@ -30,6 +30,7 @@ import java.io.IOException; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Properties; @@ -49,6 +50,7 @@ import org.hyperic.hq.product.ServerResource; import org.hyperic.hq.plugin.weblogic.jmx.WeblogicRuntimeDiscoverer; +import org.hyperic.sigar.SigarException; public class WeblogicDetector extends ServerDetector @@ -70,8 +72,7 @@ private static final String PROP_MX_SERVER = "-Dweblogic.management.server"; - private static final Log _log = LogFactory.getLog("WeblogicDetector"); - private Log log = _log; //XXX cleanup + private static final Log log = LogFactory.getLog(WeblogicDetector.class); public WeblogicDetector() { super(); @@ -338,18 +339,26 @@ long[] pids = getPids(PTQL_QUERY); for (int i=0; i<pids.length; i++) { - //nothin in the ProcArgs to indicate installpath - String cwd = getProcCwd(pids[i]); + log.debug("pid = '"+pids[i]+"'"); + String cwd = null; + try { + cwd = getSigar().getProcExe(pids[i]).getCwd(); + log.debug("cwd = '"+cwd+"'"); + } catch (SigarException e) { + log.debug("Error getting process info, pid: '"+pids[i]+"', reason: '"+e.getMessage()+"'"); + } boolean haveCwd = cwd != null; //9.1-specific since config.xml no longer tells us //this is an admin server, check the args for this prop, //which if found means this is a node server, skip it. String[] args = getProcArgs(pids[i]); + log.debug("args = "+Arrays.asList(args)); for (int j=0; j<args.length; j++) { String arg = args[j]; if (arg.startsWith(PROP_MX_SERVER)) { haveCwd = false; + log.debug(PROP_MX_SERVER+" found"); break; } else if (!haveCwd && arg.startsWith("-D")) { @@ -359,6 +368,7 @@ String path = arg.substring(ix+1).trim(); if (isAdminDir(path)) { cwd = path; + log.debug("cwd = '"+cwd+"'"); haveCwd = true; } } @@ -422,7 +432,7 @@ installpath = getInstallRoot(arg); if (installpath != null) { - _log.debug(WeblogicProductPlugin.PROP_INSTALLPATH + "=" + + log.debug(WeblogicProductPlugin.PROP_INSTALLPATH + "=" + installpath + " (derived from " + args[j] + ")"); break; } Modified: trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/ApplicationQuery.java =================================================================== --- trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/ApplicationQuery.java 2010-04-22 17:39:44 UTC (rev 14536) +++ trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/ApplicationQuery.java 2010-04-22 19:15:40 UTC (rev 14537) @@ -26,24 +26,23 @@ package org.hyperic.hq.plugin.weblogic.jmx; import javax.management.MBeanServer; -import javax.management.MalformedObjectNameException; import javax.management.ObjectName; +import javax.management.AttributeNotFoundException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.hyperic.hq.plugin.weblogic.WeblogicMetric; import org.hyperic.hq.plugin.weblogic.WeblogicProductPlugin; public class ApplicationQuery extends ServiceQuery { - public static final String MBEAN_TYPE = "ApplicationRuntime"; + private static final Log log = LogFactory.getLog("ApplicationQuery"); + public static final String MBEAN_TYPE = "ApplicationRuntime"; public static final String MBEAN_TYPE_61 = "ApplicationConfig"; private static final String ATTR_EAR = "EAR"; - - private static final String[] ATTRS = { - "Path", ATTR_NOTES, - }; - private static final String[] EAR_ATTRS = { ATTR_EAR }; private static final WeblogicQuery[] COMPONENTS = { @@ -57,7 +56,7 @@ private String mbeanName; public String[] getAttributeNames() { - return ATTRS; + return EAR_ATTRS; } public WeblogicQuery[] getChildQueries() { @@ -85,9 +84,12 @@ return WeblogicMetric.PROP_APP; } - public boolean getAttributes(MBeanServer mServer, - ObjectName name) { + public boolean isEAR(){ + return "true".equalsIgnoreCase(getAttribute(ATTR_EAR)); + } + public boolean getAttributes(MBeanServer mServer, + ObjectName name) { String appName = name.getKeyProperty("Name"); ServerQuery server = (ServerQuery)getParent(); @@ -101,35 +103,13 @@ } if (server.getDiscover().isInternalApp(appName)) { + log.debug(appName+" is a internal Application"); return false; } - if (isServer91()) { - super.getAttributes(mServer, name, EAR_ATTRS); - if ("false".equals(getAttribute(ATTR_EAR))) { - //internal stuff and wierdo data source containers - return false; - } - } - setName(appName); + super.getAttributes(mServer, name); - String appMBeanName = - name.getDomain() + ":" + - "Name=" + appName + "," + - "Type=Application"; - - ObjectName appMBean; - try { - appMBean = new ObjectName(appMBeanName); - } catch (MalformedObjectNameException e) { - //notgonnahappen - WeblogicDiscover.getLog().error(e.getMessage(), e); - return true; - } - - super.getAttributes(mServer, appMBean, ATTRS); - return true; } } Modified: trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/DynamicServiceQuery.java =================================================================== --- trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/DynamicServiceQuery.java 2010-04-22 17:39:44 UTC (rev 14536) +++ trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/DynamicServiceQuery.java 2010-04-22 19:15:40 UTC (rev 14537) @@ -113,15 +113,15 @@ //returned by the server this should not happen. //however, it is possible when nodes are not properly //configured. - logAttrFailure(name, e); + logAttrFailure(name, attrNames,e); return false; } catch (ReflectionException e) { //this should not happen either - logAttrFailure(name, e); + logAttrFailure(name, attrNames,e); return false; }catch (IOException e) { //this should not happen either - logAttrFailure(name, e); + logAttrFailure(name, attrNames,e); return false; } Modified: trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicDiscover.java =================================================================== --- trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicDiscover.java 2010-04-22 17:39:44 UTC (rev 14536) +++ trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicDiscover.java 2010-04-22 19:15:40 UTC (rev 14537) @@ -191,18 +191,14 @@ WeblogicQuery type = query.cloneInstance(); if (type.getAttributes(mServer, obj)) { types.add(type); - } - else { - continue; - } + WeblogicQuery[] childQueries = query.getChildQueries(); - WeblogicQuery[] childQueries = query.getChildQueries(); - - for (int i = 0; i < childQueries.length; i++) { - WeblogicQuery childQuery = childQueries[i]; - childQuery.setParent(type); - childQuery.setVersion(type.getVersion()); - find( mServer, childQuery, types); + for (int i = 0; i < childQueries.length; i++) { + WeblogicQuery childQuery = childQueries[i]; + childQuery.setParent(type); + childQuery.setVersion(type.getVersion()); + find( mServer, childQuery, types); + } } } } Modified: trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicQuery.java =================================================================== --- trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicQuery.java 2010-04-22 17:39:44 UTC (rev 14536) +++ trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicQuery.java 2010-04-22 19:15:40 UTC (rev 14537) @@ -27,6 +27,7 @@ import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -37,6 +38,8 @@ import javax.management.MBeanServer; import javax.management.ObjectName; import javax.management.ReflectionException; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; import org.hyperic.hq.plugin.weblogic.WeblogicConfig; import org.hyperic.hq.plugin.weblogic.WeblogicProductPlugin; @@ -54,6 +57,8 @@ private static final String[] NOOP_ATTRIBUTE_NAMES = new String[0]; private static final Properties NOOP_PROPERTIES = new Properties(); + private static final Log log = LogFactory.getLog(WeblogicQuery.class); + public WeblogicQuery cloneInstance() { WeblogicQuery query; @@ -85,9 +90,11 @@ return getAttributes(mServer, name, getAttributeNames()); } - protected void logAttrFailure(ObjectName name, Exception e) { - String msg = "Failed to get attributes for " + name; - WeblogicDiscover.getLog().debug(msg, e); + protected void logAttrFailure(ObjectName name, String[] attrNames, Exception e) { + if (log.isDebugEnabled()) { + String msg = "attributes " + Arrays.asList(attrNames) + " not found for '" + name+"' : "+e; + log.debug(msg); + } } public boolean getAttributes(MBeanServer mServer, @@ -111,11 +118,11 @@ //returned by the server this should not happen. //however, it is possible when nodes are not properly //configured. - logAttrFailure(name, e); + logAttrFailure(name,attrNames, e); return false; } catch (ReflectionException e) { //this should not happen either - logAttrFailure(name, e); + logAttrFailure(name,attrNames, e); return false; } Modified: trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicRuntimeDiscoverer.java =================================================================== --- trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicRuntimeDiscoverer.java 2010-04-22 17:39:44 UTC (rev 14536) +++ trunk/plugins/weblogic/src/org/hyperic/hq/plugin/weblogic/jmx/WeblogicRuntimeDiscoverer.java 2010-04-22 19:15:40 UTC (rev 14537) @@ -299,10 +299,20 @@ pluginUpdater.updateServiceTypes(plugin.getProductPlugin(), serviceTypes); } - for (int k = 0; k < services.size(); k++) { - aServices.add(generateService((ServiceQuery) services.get(k))); - } + for (int k = 0; k < services.size(); k++) { + boolean valid = true; + ServiceQuery service = (ServiceQuery) services.get(k); + if (service instanceof ApplicationQuery) { + valid = ((ApplicationQuery) service).isEAR(); + } + if (valid) { + aServices.add(generateService(service)); + } else { + log.debug("skipped service:"+service.getName()); + } + } + AIServiceValue[] aiservices = (AIServiceValue[]) aServices.toArray(new AIServiceValue[0]); aServer.setAIServiceValues(aiservices); |