Added TNS support with failover in LILOM
GetServiceName can handle TNS con strings No support yet in JavaMonWeb
Showing
7 changed files
with
63 additions
and
11 deletions
No preview for this file type
No preview for this file type
LILJM/lib/jconsole_damk321s2.bat
0 → 100644
| 1 | javaw.exe -Dcom.sun.management.jmxremote.ssl=false -cp "wls-12.2.1.2.0.4/wljmxclient.jar;jconsole.1.8.0_91.jar" sun.tools.jconsole.JConsole "service:jmx:rmi:///jndi/iiop://damk321s2.da.kap.rsv.se:17010/weblogic.management.mbeanservers.runtime" | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
LILJM/lib/wls-12.2.1.2.0.4/wlclient.jar
0 → 100644
No preview for this file type
LILJM/lib/wls-12.2.1.2.0.4/wljmxclient.jar
0 → 100644
No preview for this file type
| ... | @@ -6,6 +6,8 @@ import java.util.Hashtable; | ... | @@ -6,6 +6,8 @@ import java.util.Hashtable; |
| 6 | import java.util.Properties; | 6 | import java.util.Properties; |
| 7 | import java.util.concurrent.locks.Lock; | 7 | import java.util.concurrent.locks.Lock; |
| 8 | import java.util.concurrent.locks.ReentrantLock; | 8 | import java.util.concurrent.locks.ReentrantLock; |
| 9 | import java.util.regex.Matcher; | ||
| 10 | import java.util.regex.Pattern; | ||
| 9 | 11 | ||
| 10 | public class OraMon { | 12 | public class OraMon { |
| 11 | Connection conn = null; | 13 | Connection conn = null; |
| ... | @@ -13,6 +15,7 @@ public class OraMon { | ... | @@ -13,6 +15,7 @@ public class OraMon { |
| 13 | String conUser = "system"; | 15 | String conUser = "system"; |
| 14 | String conPass = "passw0rd"; | 16 | String conPass = "passw0rd"; |
| 15 | String dbName = null; | 17 | String dbName = null; |
| 18 | String serviceName = null; | ||
| 16 | 19 | ||
| 17 | Boolean isPDB = false; | 20 | Boolean isPDB = false; |
| 18 | Boolean isCDB = false; | 21 | Boolean isCDB = false; |
| ... | @@ -47,17 +50,30 @@ public class OraMon { | ... | @@ -47,17 +50,30 @@ public class OraMon { |
| 47 | } | 50 | } |
| 48 | 51 | ||
| 49 | public String getServiceName() { | 52 | public String getServiceName() { |
| 53 | if(this.serviceName != null) return this.serviceName; | ||
| 50 | if(this.conString != null) { | 54 | if(this.conString != null) { |
| 55 | if(this.conString.contains("SERVICE_NAME=")) { | ||
| 56 | //TNS format | ||
| 57 | Pattern pat = Pattern.compile("SERVICE_NAME=(\\w+)"); | ||
| 58 | Matcher m = pat.matcher(this.conString); | ||
| 59 | if(m.find()) { | ||
| 60 | this.serviceName = m.group(1); | ||
| 61 | } else { | ||
| 62 | this.serviceName = null; | ||
| 63 | } | ||
| 64 | } else { | ||
| 51 | int last = this.conString.lastIndexOf('/'); | 65 | int last = this.conString.lastIndexOf('/'); |
| 52 | if(last >=0) | 66 | if(last >=0) |
| 53 | return this.conString.substring(last +1); | 67 | this.serviceName = this.conString.substring(last +1); |
| 54 | else { | 68 | else { |
| 55 | last = this.conString.lastIndexOf(':'); | 69 | last = this.conString.lastIndexOf(':'); |
| 56 | return this.conString.substring(last +1); | 70 | this.serviceName = this.conString.substring(last +1); |
| 71 | } | ||
| 57 | } | 72 | } |
| 58 | } else { | 73 | } else { |
| 59 | return null; | 74 | this.serviceName = null; |
| 60 | } | 75 | } |
| 76 | return this.serviceName; | ||
| 61 | } | 77 | } |
| 62 | 78 | ||
| 63 | //NUM_CPUS | 79 | //NUM_CPUS |
| ... | @@ -117,7 +133,13 @@ public class OraMon { | ... | @@ -117,7 +133,13 @@ public class OraMon { |
| 117 | } | 133 | } |
| 118 | 134 | ||
| 119 | public String getDBName() { | 135 | public String getDBName() { |
| 120 | return this.dbName; | 136 | // Returns the instance name unless we are a PDB, in that case the service name from the con string is returned instead. |
| 137 | if(isPDB) return getServiceName(); | ||
| 138 | else return this.dbName; | ||
| 139 | } | ||
| 140 | |||
| 141 | public boolean isPDB() { | ||
| 142 | return isPDB; | ||
| 121 | } | 143 | } |
| 122 | 144 | ||
| 123 | public double getOsBusyPercent() throws Throwable { | 145 | public double getOsBusyPercent() throws Throwable { |
| ... | @@ -257,19 +279,28 @@ public class OraMon { | ... | @@ -257,19 +279,28 @@ public class OraMon { |
| 257 | // We don't know, check if the CONTAINERS view exists in the database | 279 | // We don't know, check if the CONTAINERS view exists in the database |
| 258 | rset = stmt.executeQuery("select count(*) from SYS.ALL_VIEWS where VIEW_NAME = 'V_$CONTAINERS'"); | 280 | rset = stmt.executeQuery("select count(*) from SYS.ALL_VIEWS where VIEW_NAME = 'V_$CONTAINERS'"); |
| 259 | if(rset.next()) { | 281 | if(rset.next()) { |
| 260 | if(rset.getInt(0) == 1) { | 282 | if(rset.getInt(1) == 1) { |
| 261 | // We found the containers view. Enable container handling | 283 | // We found the containers view. Enable container handling |
| 262 | hasContainers = true; | 284 | hasContainers = true; |
| 263 | if(getServiceName().equals(this.dbName)) isCDB = true; | 285 | String serviceName = getServiceName(); |
| 286 | if(serviceName != null) { | ||
| 287 | if(serviceName.equals(this.dbName)) isCDB = true; | ||
| 288 | else isPDB = true; | ||
| 289 | } else { | ||
| 290 | // Servicename is null, treat as CDB | ||
| 291 | isCDB = true; | ||
| 292 | isPDB = false; | ||
| 293 | } | ||
| 264 | } | 294 | } |
| 265 | } | 295 | } |
| 266 | } | 296 | } |
| 267 | 297 | ||
| 268 | // If we have containers, but we are not the CDB, then we are a PDB. | 298 | // If we have containers, but we are not the CDB, then we are a PDB. |
| 269 | // At this point we should close the connections, and ask the CDB OraMon object to getData() instead, and update us. | 299 | // We should as the CDB object for our data |
| 270 | if(hasContainers && isCDB == false) { | 300 | if(isPDB) { |
| 271 | 301 | // TODO: Find the CDB OraMon object, get the data we need from it's cached CON tables | |
| 272 | } | 302 | } else { |
| 303 | // All other cases (CDB or an instance without containers) | ||
| 273 | 304 | ||
| 274 | //Get the entire V_$OSSTAT table from DB | 305 | //Get the entire V_$OSSTAT table from DB |
| 275 | colOsStat.update(stmt.executeQuery("select systimestamp, stat_name, value from V$OSSTAT")); | 306 | colOsStat.update(stmt.executeQuery("select systimestamp, stat_name, value from V$OSSTAT")); |
| ... | @@ -292,6 +323,7 @@ public class OraMon { | ... | @@ -292,6 +323,7 @@ public class OraMon { |
| 292 | 323 | ||
| 293 | //Get the entire V_$SYSSTAT table from DB | 324 | //Get the entire V_$SYSSTAT table from DB |
| 294 | colSysStat.update(stmt.executeQuery("select systimestamp, name, value from V$SYSSTAT")); | 325 | colSysStat.update(stmt.executeQuery("select systimestamp, name, value from V$SYSSTAT")); |
| 326 | } | ||
| 295 | 327 | ||
| 296 | stmt.close(); | 328 | stmt.close(); |
| 297 | getDataSucess++; | 329 | getDataSucess++; | ... | ... |
| ... | @@ -11,7 +11,26 @@ public class TestRunner { | ... | @@ -11,7 +11,26 @@ public class TestRunner { |
| 11 | /** | 11 | /** |
| 12 | * @param args | 12 | * @param args |
| 13 | */ | 13 | */ |
| 14 | public static void main(String[] args) throws Throwable{ | 14 | public static void main(String[] args) throws Throwable { |
| 15 | //runner1(); | ||
| 16 | //test1(); | ||
| 17 | testTns(); | ||
| 18 | } | ||
| 19 | |||
| 20 | public static void test1() throws Throwable { | ||
| 21 | OraMon mon = new OraMon("jdbc:oracle:thin:@//u02822.kap.rsv.se:1526/DB1K06","dbsnmp","dbsnmp"); // CDB | ||
| 22 | System.out.println("getData returned: " + mon.getData()); | ||
| 23 | System.out.println("getDatabaseName: " + mon.getDBName()); | ||
| 24 | } | ||
| 25 | |||
| 26 | public static void testTns() throws Throwable { | ||
| 27 | OraMon mon = new OraMon("jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(Host=u00153.kap.rsv.se)(Port=1526))(ADDRESS=(PROTOCOL=TCP)(Host=u00154.kap.rsv.se)(Port=1526)))(CONNECT_DATA=(SERVICE_NAME=PB1K001)))","dbsnmp","dbsnmp"); // PDB using TNS | ||
| 28 | System.out.println("getData returned: " + mon.getData()); | ||
| 29 | System.out.println("getDatabaseName: " + mon.getDBName()); | ||
| 30 | System.out.println("getServiceName: " + mon.getServiceName()); | ||
| 31 | } | ||
| 32 | |||
| 33 | public static void runner1() throws Throwable { | ||
| 15 | // TODO Auto-generated method stub | 34 | // TODO Auto-generated method stub |
| 16 | 35 | ||
| 17 | //ArrayList<OraMon> oraList = new ArrayList<OraMon>(); | 36 | //ArrayList<OraMon> oraList = new ArrayList<OraMon>(); | ... | ... |
-
Please register or sign in to post a comment