From: <gla...@hy...> - 2009-11-05 19:25:51
|
Author: glaullon Date: 2009-11-05 11:25:39 -0800 (Thu, 05 Nov 2009) New Revision: 13928 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=13928 Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/ConnectionPoolCollector.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/EJBCollector.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereCollector.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereDetector.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereProductPlugin.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereServerCollector.java trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereUtil.java Log: support WAS 7 Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/ConnectionPoolCollector.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/ConnectionPoolCollector.java 2009-11-05 19:25:20 UTC (rev 13927) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/ConnectionPoolCollector.java 2009-11-05 19:25:39 UTC (rev 13928) @@ -5,10 +5,10 @@ * Kit or the Hyperic Client Development Kit - this is merely considered * normal use of the program, and does *not* fall under the heading of * "derived work". - * + * * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. * This file is part of HQ. - * + * * HQ is free software; you can redistribute it and/or modify * it under the terms version 2 of the GNU General Public License as * published by the Free Software Foundation. This program is distributed @@ -16,7 +16,7 @@ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -99,7 +99,7 @@ "j2eeType=JDBCResource," + "name=" + getModuleName() + "," + getProcessAttributes()); - + this.name = resolve(mServer, this.name); } Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/EJBCollector.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/EJBCollector.java 2009-11-05 19:25:20 UTC (rev 13927) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/EJBCollector.java 2009-11-05 19:25:39 UTC (rev 13928) @@ -5,10 +5,10 @@ * Kit or the Hyperic Client Development Kit - this is merely considered * normal use of the program, and does *not* fall under the heading of * "derived work". - * + * * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. * This file is part of HQ. - * + * * HQ is free software; you can redistribute it and/or modify * it under the terms version 2 of the GNU General Public License as * published by the Free Software Foundation. This program is distributed @@ -16,7 +16,7 @@ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -47,7 +47,7 @@ "J2EEApplication=" + app + "," + "name=" + ejb + "," + getProcessAttributes()); - + this.name = resolve(mServer, this.name); } Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereCollector.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereCollector.java 2009-11-05 19:25:20 UTC (rev 13927) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereCollector.java 2009-11-05 19:25:39 UTC (rev 13928) @@ -5,10 +5,10 @@ * Kit or the Hyperic Client Development Kit - this is merely considered * normal use of the program, and does *not* fall under the heading of * "derived work". - * + * * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. * This file is part of HQ. - * + * * HQ is free software; you can redistribute it and/or modify * it under the terms version 2 of the GNU General Public License as * published by the Free Software Foundation. This program is distributed @@ -16,7 +16,7 @@ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -73,13 +73,13 @@ protected String getServerAttributes() { return "J2EEServer=" + getServerName() + "," + - "node=" + getNodeName(); + "node=" + getNodeName(); } protected String getProcessAttributes() { return "process=" + getServerName() + "," + - "node=" + getNodeName(); + "node=" + getNodeName(); } protected void init() throws PluginException { @@ -124,7 +124,7 @@ log.error(e.getMessage(), e); return null; } - + } protected ObjectName resolve(AdminClient mServer, ObjectName name) @@ -185,7 +185,7 @@ log.error("Unsupported stat type: " + stat.getName() + "/" + stat.getClass().getName()); return MetricValue.VALUE_NONE; - } + } } protected double getStatCount(Stats stats, String metric) { @@ -200,7 +200,7 @@ for (int i=0; i<attrs.length; i++) { String[] entry = attrs[i]; String statKey = entry[0]; - String pmiKey = entry.length == 1 ? statKey : entry[1]; + String pmiKey = entry.length == 1 ? statKey : entry[1]; double val = getStatCount(stats, statKey); if (val == MetricValue.VALUE_NONE) { continue; Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereDetector.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereDetector.java 2009-11-05 19:25:20 UTC (rev 13927) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereDetector.java 2009-11-05 19:25:39 UTC (rev 13928) @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.Reader; +import java.util.Arrays; import java.util.ArrayList; import java.util.List; import java.util.Properties; @@ -63,7 +64,7 @@ WebsphereProductPlugin.PROP_ADMIN_HOST }; - protected Log log = + static protected Log log = LogFactory.getLog(WebsphereDetector.class.getName()); private static final String PTQL_QUERY = @@ -116,6 +117,8 @@ } private File findServerIndex() { + log.debug("[findServerIndex] installpath='"+this.installpath+"'"); + //any serverindex.xml will do. File[] cells = new File(this.installpath + "/config/cells").listFiles(); @@ -124,6 +127,8 @@ return null; } + log.debug("[findServerIndex] cells="+Arrays.asList(cells)); + for (int i=0; i<cells.length; i++) { File[] nodes = new File(cells[i], "nodes").listFiles(); @@ -135,6 +140,7 @@ for (int j=0; j<nodes.length; j++) { File index = new File(nodes[j], "serverindex.xml"); if (index.exists() && index.canRead()) { + log.debug("[findServerIndex] index='"+index.getAbsolutePath()+"'"); return index; } } @@ -361,52 +367,49 @@ static final String VERSION_START = "<version>"; static final String VERSION_END = "</version>"; - protected String getComponentVersion(File file) { + protected static String getComponentVersion(File file) { Reader reader = null; + String res = ""; try { reader = new FileReader(file); - BufferedReader buffer = - new BufferedReader(reader); + BufferedReader buffer = new BufferedReader(reader); String line; while ((line = buffer.readLine()) != null) { line = line.trim(); - if (line.length() == 0) { - continue; + int ix = line.indexOf(VERSION_END); + if (line.startsWith(VERSION_START) && (ix != -1)) { + res = line.substring(VERSION_START.length(), ix).trim(); } - int ix; - if (!(line.startsWith(VERSION_START) && - ((ix = line.indexOf(VERSION_END)) != -1))) - { - continue; - } - - return line.substring(VERSION_START.length(), ix).trim(); } - - return null; } catch (IOException e) { - return null; + if (log.isDebugEnabled()) { + log.error("Error getting the WAS version: " + e.getMessage(), e); + } + res = null; } finally { if (reader != null) { try { reader.close(); - } catch (IOException e) {} + } catch (IOException e) { + } } } + return res; } protected boolean isComponentVersion(File file) { String version = getComponentVersion(file); - if (version == null) { - return false; - } + log.debug("version= '"+version+"' type='"+getTypeInfo().getVersion()+"'"); return version.startsWith(getTypeInfo().getVersion()); } protected List getServerList(File serverDir, String version) throws PluginException { + + log.debug("[getServerList] ("+version+") "+serverDir); + File controlScript = null; if (!isServiceControl()) { @@ -532,7 +535,7 @@ for (int i=0; i<processes.size(); i++) { Process process = (Process)processes.get(i); - List found = getServerList(new File(process.installRoot), null); + List found = getServerList(new File(process.serverRoot), null); if (found != null) { servers.addAll(found); } Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereProductPlugin.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereProductPlugin.java 2009-11-05 19:25:20 UTC (rev 13927) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereProductPlugin.java 2009-11-05 19:25:39 UTC (rev 13928) @@ -5,10 +5,10 @@ * Kit or the Hyperic Client Development Kit - this is merely considered * normal use of the program, and does *not* fall under the heading of * "derived work". - * + * * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. * This file is part of HQ. - * + * * HQ is free software; you can redistribute it and/or modify * it under the terms version 2 of the GNU General Public License as * published by the Free Software Foundation. This program is distributed @@ -16,7 +16,7 @@ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -50,7 +50,7 @@ import org.hyperic.sigar.win32.Win32Exception; public class WebsphereProductPlugin extends ProductPlugin { - + public static final String NAME = "websphere"; public static final String SERVER_NAME = "WebSphere"; @@ -78,7 +78,7 @@ public static final String PROP_SERVER_NODE = "server.node"; public static final String PROP_SERVER_NAME = "server.name"; public static final String PROP_SERVER_PORT = "server.port"; - + public static final String PROP_THRPOOL_NAME = "thrpool"; public static final String PROP_CONNPOOL_NAME = "connpool"; public static final String PROP_APP_NAME = "app"; @@ -102,7 +102,8 @@ "5.1.0.0", "5.0.0.0", "6.0.0.0", - "6.1.0.0" + "6.1.0.0", + "7.0.0.0" }; private static Log log = LogFactory.getLog("WebsphereProductPlugin"); @@ -124,7 +125,7 @@ } String javaHome = System.getProperty("java.home"); - + File dir = new File(javaHome); //exists in both 4.0 and 5.0 @@ -219,7 +220,7 @@ } if (dir == null) { - log.debug("Unable to determine " + PROP_INSTALLPATH); + log.debug("Unable to determine " + PROP_INSTALLPATH); return null; } else { @@ -251,12 +252,12 @@ for (int j=0; j<jars.length; j++) { if (!jars[j].endsWith(".jar")) { continue; + } + + log.debug("Classpath += " + dir + jars[j]); + path.add(dir + jars[j]); } - - log.debug("Classpath += " + dir + jars[j]); - path.add(dir + jars[j]); } - } //jar names minus version "_6.1.0.jar" private void addClassPathOSGi(List path, @@ -273,10 +274,9 @@ new File(dir).list(new FilenameFilter() { public boolean accept(File dir, String name) { int ix = name.indexOf('_'); - if (ix == -1) { - return false; + if (ix != -1) { + name = name.substring(0, ix); } - name = name.substring(0, ix); return wantedJars.get(name) != null; } }); @@ -307,7 +307,7 @@ continue; } InputStream entryStream = jar.getInputStream(entry); - + os.putNextEntry(entry); while ((n = entryStream.read(buffer)) != -1) { os.write(buffer, 0, n); @@ -362,12 +362,12 @@ if (jar.isDirectory() || !jars[j].endsWith(".jar")) { continue; } - + if (jars[j].startsWith("com.ibm.ws.webservices.thinclient")) { // skip continue; } - + log.debug("classpath += " + jar); if (jars[j].startsWith("com.ibm.ws.runtime_")) { jar = runtimeJarHack(jar); @@ -381,17 +381,55 @@ private String[] getClassPathOSGi(String installDir) { ArrayList path = new ArrayList(); - final String[] plugins = { - "com.ibm.ws.runtime", - "com.ibm.ws.security.crypto", - "org.eclipse.osgi", - }; - addClassPathOSGi(path, installDir + "/plugins/", plugins); + String v = WebsphereDetector.getComponentVersion(new File(installDir, "properties/version/WAS.product")); + if (v.startsWith("6")) { - final String[] runtimes = { - "com.ibm.ws.webservices.thinclient", - }; - addClassPathOSGi(path, installDir + "/runtimes/", runtimes); + final String[] lib = { + "bootstrap.jar", + "j2ee.jar", + "launchclient.jar", + "mail-impl.jar" + }; + addClassPathOSGi(path, installDir + "/lib/", lib); + + final String[] plugins = { + "com.ibm.ws.bootstrap", + "com.ibm.ws.emf", + "com.ibm.ws.security.crypto", + "com.ibm.ws.wccm", + "org.eclipse.core.runtime", + "org.eclipse.osgi", + "com.ibm.ws.runtime",}; + addClassPathOSGi(path, installDir + "/plugins/", plugins); + + final String[] runtimes = { + "com.ibm.ws.admin.client",}; + addClassPathOSGi(path, installDir + "/runtimes/", runtimes); + + } else if (v.startsWith("7")) { + final String[] lib = { + "bootstrap.jar",}; + addClassPathOSGi(path, installDir + "/lib/", lib); + + final String[] plugins = { + "com.ibm.ffdc.jar", + "com.ibm.ws.security.crypto.jar", + "com.ibm.ws.admin.core.jar", + "com.ibm.ws.runtime.jar", + "com.ibm.ws.emf.jar", + "org.eclipse.emf.ecore.jar", + "org.eclipse.emf.common.jar", + "com.ibm.ws.prereq.soap.jar", + "com.ibm.ws.prereq.javamail.jar", + "com.ibm.wsfp.main.jar", + "javax.j2ee.management.jar",}; + addClassPathOSGi(path, installDir + "/plugins/", plugins); + } else { + if (log.isDebugEnabled()) { + log.error("Unknown version '" + v + "'"); + } + } + path.add("pdk/lib/mx4j/hq-jmx.jar"); String[] cp = new String[path.size()]; path.toArray(cp); @@ -433,17 +471,17 @@ installDir + File.separator + "properties" + File.separator + "sas.client.props"; - String corbaConfig = + String corbaConfig = managerProps.getProperty("websphere.CORBA.ConfigURL", defaultCorbaConfig); System.setProperty("com.ibm.CORBA.ConfigURL", "file:" + corbaConfig); - String defaultSoapProps = + String defaultSoapProps = "properties" + File.separator + "soap.client.props"; - File installPropertiesDir = + File installPropertiesDir = getInstallPropertiesDir(installDir, defaultSoapProps); String soapConfig = null; File soapConfigFile = null; @@ -451,16 +489,16 @@ String defaultSoapConfig = installPropertiesDir.getPath(); log.debug("default soap config is " + defaultSoapConfig); - soapConfig = + soapConfig = managerProps.getProperty("websphere.SOAP.ConfigURL", defaultSoapConfig); soapConfigFile = new File(soapConfig); hasSoapConfig = soapConfigFile.exists(); } - + if (hasSoapConfig) { - log.debug("Using soap properties: " + soapConfig); + log.debug("Using soap properties: " + soapConfig); System.setProperty("com.ibm.SOAP.ConfigURL", "file:" + soapConfig); } @@ -479,7 +517,7 @@ new File(soapConfigFile.getParent(), "ssl.client.props"); } - + if (sslConfigFile != null && sslConfigFile.exists()) { log.debug("Using ssl properties: " + sslConfigFile); System.setProperty("com.ibm.SSL.ConfigURL", @@ -571,21 +609,21 @@ "pdk/lib/mx4j/hq-jmx.jar" }; } - + File getInstallPropertiesDir(String installDir, String lookFor) { File result = getInstallPropertiesDirForWAS61(lookFor); - + if (result == null) { result = getInstallPropertiesDirForWAS60(installDir, lookFor); } - + return result; } - + File getInstallPropertiesDirForWAS61(String lookFor) { - + File result = null; - + List servers = getServerProcessList(); if (servers.size() != 0) { for (Iterator it = servers.iterator(); it.hasNext(); ) { @@ -603,16 +641,16 @@ } } } - + return result; } - + List getServerProcessList() { return WebsphereDetector.getServerProcessList(); } File getInstallPropertiesDirForWAS60(String installDir, String lookFor) { - + File result = null; File profileDir = new File(installDir + File.separator + "profiles"); @@ -649,7 +687,7 @@ } } } - + return result; } } Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereServerCollector.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereServerCollector.java 2009-11-05 19:25:20 UTC (rev 13927) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereServerCollector.java 2009-11-05 19:25:39 UTC (rev 13928) @@ -87,26 +87,6 @@ this.name = null; } } - else if (module.equals("servletSessionsModule")) { - this.name = null; //XXX - setSource(module); - } - else if (module.equals("webappModule")) { - this.name = null; //XXX - setSource(module); - } - else if (module.equals("beanModule")) { - this.name = null; //XXX - setSource(module); - } - else if (module.equals("threadPoolModule")) { - this.name = null; //XXX - setSource(module); - } - else if (module.equals("connectionPoolModule")) { - this.name = null; //XXX - setSource(module); - } } public void collect() { Modified: trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereUtil.java =================================================================== --- trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereUtil.java 2009-11-05 19:25:20 UTC (rev 13927) +++ trunk/plugins/websphere/src/org/hyperic/hq/plugin/websphere/WebsphereUtil.java 2009-11-05 19:25:39 UTC (rev 13928) @@ -5,10 +5,10 @@ * Kit or the Hyperic Client Development Kit - this is merely considered * normal use of the program, and does *not* fall under the heading of * "derived work". - * + * * Copyright (C) [2004, 2005, 2006], Hyperic, Inc. * This file is part of HQ. - * + * * HQ is free software; you can redistribute it and/or modify * it under the terms version 2 of the GNU General Public License as * published by the Free Software Foundation. This program is distributed @@ -16,7 +16,7 @@ * even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more * details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 @@ -60,14 +60,14 @@ private static HashMap cache = new HashMap(); private static Log log = LogFactory.getLog("WebSphereUtil"); - + // WAS doesn't expose these anywhere we've found yet private static final String TRUST_STORE = "javax.net.ssl.trustStore"; private static final String KEY_STORE = "javax.net.ssl.keyStore"; private static final String TRUST_STORE_PWD = "javax.net.ssl.trustStorePassword"; private static final String KEY_STORE_PWD = "javax.net.ssl.keyStorePassword"; - public static Object getRemoteMBeanValue(Metric metric) + public static Object getRemoteMBeanValue(Metric metric) throws MetricNotFoundException, MetricUnreachableException, PluginException { @@ -75,7 +75,7 @@ return getRemoteMBeanValue(metric, metric.getAttributeName()); } - public static Object getRemoteMBeanValue(Metric metric, String attributeName) + public static Object getRemoteMBeanValue(Metric metric, String attributeName) throws MetricNotFoundException, MetricUnreachableException, PluginException { @@ -89,7 +89,7 @@ } catch (MalformedObjectNameException e) { throw new MetricInvalidException(e.getMessage(), e); } - + try { return mServer.getAttribute(objName, metric.getAttributeName()); @@ -117,7 +117,7 @@ throws MetricUnreachableException { Properties props = getAdminProperties(cfg); - + if (log.isDebugEnabled()) { log.debug("Attempting to create admin client with props " + props + " from config " + cfg); @@ -147,26 +147,26 @@ String port = cfg.getProperty(WebsphereProductPlugin.PROP_ADMIN_PORT, "8880"); - + Properties props = new Properties(); - + props.setProperty(AdminClient.CONNECTOR_TYPE, AdminClient.CONNECTOR_TYPE_SOAP); - + props.setProperty(AdminClient.CONNECTOR_HOST, host); - + props.setProperty(AdminClient.CONNECTOR_PORT, port); - + String user = cfg.getProperty(AdminClient.USERNAME, ""); String pass = cfg.getProperty(AdminClient.PASSWORD, ""); - + // user and pass cannot be null because getProperty() is called // with default values if (!user.equals("") && !pass.equals("")) { props.setProperty(AdminClient.USERNAME, user); props.setProperty(AdminClient.PASSWORD, pass); props.setProperty(AdminClient.CONNECTOR_SECURITY_ENABLED, "true"); - + // Set the ssl props, if they're available. As of this writing, there are no // publicly-available constants for the prop keys, so they're kept in this source file. String trustStore = cfg.getProperty(TRUST_STORE); @@ -181,7 +181,7 @@ props.setProperty(KEY_STORE_PWD, keyStorePwd); } } - + return props; } @@ -220,7 +220,7 @@ MetricNotFoundException { double count = 0; - + try { Set beans = mServer.queryNames(query, null); for (Iterator it=beans.iterator(); it.hasNext();) { @@ -273,7 +273,7 @@ if (log.isDebugEnabled()) { log.debug(name + " resolved to: " + fullName); } - + return fullName; } catch (Exception e) { String msg = @@ -343,7 +343,7 @@ */ public static Object invoke(String objectName, Properties props, - String method, + String method, Object[] args, String[] sig) throws PluginException { |