From: <sc...@hy...> - 2009-12-15 20:51:59
|
Author: scottmf Date: 2009-12-15 12:51:47 -0800 (Tue, 15 Dec 2009) New Revision: 14094 URL: http://svn.hyperic.org/?view=rev&root=Hyperic+HQ&revision=14094 Modified: trunk/plugins/oracle/etc/hq-plugin.xml trunk/plugins/oracle/src/org/hyperic/hq/plugin/oracle/OracleServerDetector.java Log: [HHQ-3577] fixed up installpath and added the ability to use tnsnames in the jdbc url Modified: trunk/plugins/oracle/etc/hq-plugin.xml =================================================================== --- trunk/plugins/oracle/etc/hq-plugin.xml 2009-12-15 20:44:25 UTC (rev 14093) +++ trunk/plugins/oracle/etc/hq-plugin.xml 2009-12-15 20:51:47 UTC (rev 14094) @@ -77,7 +77,7 @@ </script> <classpath> - <include name="pdk/lib/jdbc/oracle12.jar"/> + <include name="pdk/lib/jdbc/ojdbc14.jar"/> </classpath> <!-- we use a dummy jmx object name --> Modified: trunk/plugins/oracle/src/org/hyperic/hq/plugin/oracle/OracleServerDetector.java =================================================================== --- trunk/plugins/oracle/src/org/hyperic/hq/plugin/oracle/OracleServerDetector.java 2009-12-15 20:44:25 UTC (rev 14093) +++ trunk/plugins/oracle/src/org/hyperic/hq/plugin/oracle/OracleServerDetector.java 2009-12-15 20:51:47 UTC (rev 14094) @@ -67,6 +67,8 @@ private static final String PROP_PROC_PTQL = "process.ptql"; + private static final String PROP_TNSNAMES = "tnsnames"; + private static final String ORATAB = "/etc/oratab"; private static final Pattern _serviceNameEx = @@ -190,8 +192,12 @@ bin = new File(oracle, "bin"); } if (bin.getName().equals("bin")) { - path = oracle.getParent(); + path = bin.getParent(); } + // in HHQ-3577, changed the default installpath. Therefore we need to + // make sure that a new oracle inst is not detected, rather it should + // just modify the existing one. + String aiid = oracle.getParent(); // Make sure that oracle exists, and is a normal file if (oracle.exists() && bin.isDirectory()) { @@ -213,6 +219,7 @@ if (found) { ConfigResponse productConfig = new ConfigResponse(); ServerResource server = createServerResource(path); + server.setIdentifier(aiid); // Set custom properties ConfigResponse cprop = new ConfigResponse(); @@ -225,6 +232,11 @@ servers.add(server); } + // HHQ-3577 allow listener names in tnsnames.ora to be used in the url + String tnsDir = getTnsNamesDir(path, "network/admin/tnsnames.ora"); + if (log.isDebugEnabled()) log.debug("using tns dir as " + tnsDir); + System.setProperty("oracle.net.tns_admin", tnsDir); + return servers; } @@ -290,6 +302,13 @@ protected List discoverServices(ConfigResponse config) throws PluginException { + // HHQ-3577 allow listener names in tnsnames.ora to be used in the url + String tnsDir = getTnsNamesDir( + config.getValue(ProductPlugin.PROP_INSTALLPATH), + config.getValue(PROP_TNSNAMES)); + if (log.isDebugEnabled()) log.debug("using tns dir as " + tnsDir); + System.setProperty("oracle.net.tns_admin", tnsDir); + String url = config.getValue(OracleMeasurementPlugin.PROP_URL); if (url == null) { log.warn("No value for config property " + OracleMeasurementPlugin.PROP_URL + @@ -344,7 +363,7 @@ } // Otherwise, dump the error. throw new PluginException("Error querying for Oracle " + - "services: " + e.getMessage()); + "services: " + e.getMessage(), e); } finally { DBUtil.closeJDBCObjects(log, conn, stmt, null); @@ -555,11 +574,24 @@ return rtn; } + private String getTnsNamesDir(String installpath, String tnsnames) { + if (installpath == null || tnsnames == null) { + return ""; + } + String fs = File.separator; + String[] toks = tnsnames.split(fs); + StringBuilder rtn = new StringBuilder(); + for (int i=0; i<toks.length-1; i++) { + rtn.append(toks[i]).append(fs); + } + return installpath + fs + rtn.toString(); + } + private List getTnsServices(ConfigResponse config) { String line; BufferedReader reader = null; - String tnsnames = config.getValue("tnsnames"), + String tnsnames = config.getValue(PROP_TNSNAMES), installpath = config.getValue(ProductPlugin.PROP_INSTALLPATH); List rtn = new ArrayList(); try |