Merge branch 'master' of https://git.lightsinline.se/products/LILOM.git
Showing
15 changed files
with
176 additions
and
16 deletions
... | @@ -43,21 +43,25 @@ if(request.getParameter("action") != null) { | ... | @@ -43,21 +43,25 @@ if(request.getParameter("action") != null) { |
43 | <% } %> | 43 | <% } %> |
44 | 44 | ||
45 | <script type="text/javascript"> | 45 | <script type="text/javascript"> |
46 | function getData(type, input) { | 46 | function getData(type, input, pdb) { |
47 | // Update the data | 47 | // Update the data |
48 | var pdbAdd = ""; | ||
49 | if(pdb != "" && pdb != null) pdbAdd = "&pdbName=" + pdb; | ||
48 | var client1 = new XMLHttpRequest(); | 50 | var client1 = new XMLHttpRequest(); |
49 | client1.onreadystatechange = dataHandler; | 51 | client1.onreadystatechange = dataHandler; |
50 | client1.open("GET", "/" + type + "/getData?age=14&connectionString=" + encodeURIComponent(input)); | 52 | client1.open("GET", "/" + type + "/getData?age=14" + pdbAdd + "&connectionString=" + encodeURIComponent(input)); |
51 | client1.setRequestHeader('Cache-Control', 'no-cache'); | 53 | client1.setRequestHeader('Cache-Control', 'no-cache'); |
52 | client1.setRequestHeader('Pragma', 'no-cache'); | 54 | client1.setRequestHeader('Pragma', 'no-cache'); |
53 | client1.send(); | 55 | client1.send(); |
54 | } | 56 | } |
55 | 57 | ||
56 | function getMetrics(type, input) { | 58 | function getMetrics(type, input, pdb) { |
57 | // Get the metrics | 59 | // Get the metrics |
60 | var pdbAdd = ""; | ||
61 | if(pdb != "" && pdb != null) pdbAdd = "pdbName=" + pdb + "&"; | ||
58 | var client2 = new XMLHttpRequest(); | 62 | var client2 = new XMLHttpRequest(); |
59 | client2.onreadystatechange = metricsHandler; | 63 | client2.onreadystatechange = metricsHandler; |
60 | client2.open("GET", "/" + type + "/getMetrics?connectionString=" + encodeURIComponent(input)); | 64 | client2.open("GET", "/" + type + "/getMetrics?" + pdbAdd + "connectionString=" + encodeURIComponent(input)); |
61 | client2.setRequestHeader('Cache-Control', 'no-cache'); | 65 | client2.setRequestHeader('Cache-Control', 'no-cache'); |
62 | client2.setRequestHeader('Pragma', 'no-cache'); | 66 | client2.setRequestHeader('Pragma', 'no-cache'); |
63 | client2.send(); | 67 | client2.send(); |
... | @@ -117,8 +121,9 @@ function dataHandler() { | ... | @@ -117,8 +121,9 @@ function dataHandler() { |
117 | <input type="submit" name="action" value="remove" > | 121 | <input type="submit" name="action" value="remove" > |
118 | <input type="hidden" name="omconstr" value="<%= mon.getConString() %>"> | 122 | <input type="hidden" name="omconstr" value="<%= mon.getConString() %>"> |
119 | <input type="button" value="graph" onClick="window.open('/viewOraMon.html?<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>')"> | 123 | <input type="button" value="graph" onClick="window.open('/viewOraMon.html?<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>')"> |
120 | <input id="getDataButton" type="button" value="getData" onClick="getData('OraMonREST', '<%= mon.getConString() %>')"> | 124 | <input id="getDataButton" type="button" value="getData" onClick="getData('OraMonREST', '<%= mon.getConString() %>',this.form.pdbName.value)"> |
121 | <input id="getMetricsButton" type="button" value="getMetrics" onClick="getMetrics('OraMonREST', '<%= mon.getConString() %>')"> | 125 | <input id="getMetricsButton" type="button" value="getMetrics" onClick="getMetrics('OraMonREST', '<%= mon.getConString() %>',this.form.pdbName.value)"> |
126 | <input id="pdbName" name="pdbName" size="10"> | ||
122 | </form> | 127 | </form> |
123 | </td> | 128 | </td> |
124 | </tr> | 129 | </tr> | ... | ... |
No preview for this file type
No preview for this file type
No preview for this file type
JavaMonWeb/jetty/tests.chls
0 → 100644
No preview for this file type
... | @@ -53,10 +53,26 @@ public class OraMonRESTgetData extends HttpServlet { | ... | @@ -53,10 +53,26 @@ public class OraMonRESTgetData extends HttpServlet { |
53 | if(shortConArray.length != 2) { | 53 | if(shortConArray.length != 2) { |
54 | // Error, wrong format of string | 54 | // Error, wrong format of string |
55 | response.setStatus(HttpServletResponse.SC_BAD_REQUEST); | 55 | response.setStatus(HttpServletResponse.SC_BAD_REQUEST); |
56 | response.getWriter().println("{\"error\":true,\"msg\":\"connectionString needs to be in format jdbc:oracle:thin:@//host:port/sid with optional :username:password at the end.\"}"); | 56 | response.getWriter().println("{\"error\":true,\"msg\":\"connectionString needs to be in format jdbc:oracle:thin:@//host:port/servicename or jdbc:oracle:thin:@(<TNS Connection String>) with optional :username:password at the end.\"}"); |
57 | return; | 57 | return; |
58 | } | 58 | } |
59 | String[] shortConArray2 = shortConArray[1].split(":"); | 59 | String[] shortConArray2 = shortConArray[1].split(":"); |
60 | if(shortConArray2[0].startsWith("(")) { | ||
61 | // TNS Format | ||
62 | if(shortConArray2.length == 3) { | ||
63 | // We have a TNS connection string and username + password | ||
64 | monitor = Registry.findOrCreate(shortConArray[0] + "@" + shortConArray2[0], shortConArray2[1], shortConArray2[2]); | ||
65 | } else if (shortConArray2.length == 1) { | ||
66 | // We only have the TNS connection string, no username or password | ||
67 | monitor = Registry.find(shortConArray[0] + "@" + shortConArray2[0]); | ||
68 | } else { | ||
69 | // We have something else, not implemented | ||
70 | response.setStatus(HttpServletResponse.SC_BAD_REQUEST); | ||
71 | response.getWriter().println("{\"error\":true,\"msg\":\"connectionString needs to be in format jdbc:oracle:thin:@(<TNS Connection String>) with optional :username:password at the end.\"}"); | ||
72 | return; | ||
73 | } | ||
74 | } else { | ||
75 | // JDBC Format | ||
60 | if(shortConArray2[0].startsWith("//") && shortConArray2.length == 4) { | 76 | if(shortConArray2[0].startsWith("//") && shortConArray2.length == 4) { |
61 | // We have new style and username and password, we can try to create the monitor if it doesnt exist | 77 | // We have new style and username and password, we can try to create the monitor if it doesnt exist |
62 | monitor = Registry.findOrCreate(shortConArray[0] + "@" + shortConArray2[0] + ":" + shortConArray2[1], shortConArray2[2], shortConArray2[3]); | 78 | monitor = Registry.findOrCreate(shortConArray[0] + "@" + shortConArray2[0] + ":" + shortConArray2[1], shortConArray2[2], shortConArray2[3]); |
... | @@ -72,9 +88,10 @@ public class OraMonRESTgetData extends HttpServlet { | ... | @@ -72,9 +88,10 @@ public class OraMonRESTgetData extends HttpServlet { |
72 | } else { | 88 | } else { |
73 | // Wrong format | 89 | // Wrong format |
74 | response.setStatus(HttpServletResponse.SC_BAD_REQUEST); | 90 | response.setStatus(HttpServletResponse.SC_BAD_REQUEST); |
75 | response.getWriter().println("{\"error\":true,\"msg\":\"connectionString needs to be in format jdbc:oracle:thin:@//host:port/sid with optional :username:password at the end.\"}"); | 91 | response.getWriter().println("{\"error\":true,\"msg\":\"connectionString needs to be in format jdbc:oracle:thin:@//host:port/servicename with optional :username:password at the end.\"}"); |
76 | return; | 92 | return; |
77 | } | 93 | } |
94 | } | ||
78 | } else { | 95 | } else { |
79 | // Short con string | 96 | // Short con string |
80 | // Check that we have a valid connection string (added support to handle diffrent kinds of connection strings) | 97 | // Check that we have a valid connection string (added support to handle diffrent kinds of connection strings) |
... | @@ -94,7 +111,7 @@ public class OraMonRESTgetData extends HttpServlet { | ... | @@ -94,7 +111,7 @@ public class OraMonRESTgetData extends HttpServlet { |
94 | } | 111 | } |
95 | String conStr, usrStr, pwdStr; | 112 | String conStr, usrStr, pwdStr; |
96 | if(serviceName) { | 113 | if(serviceName) { |
97 | conStr = "jdbc:oracle:thin:@" + conStrParamArray[0] + ":" + conStrParamArray[1]; | 114 | conStr = "jdbc:oracle:thin:@//" + conStrParamArray[0] + ":" + conStrParamArray[1]; |
98 | usrStr = conStrParamArray[2]; | 115 | usrStr = conStrParamArray[2]; |
99 | pwdStr = conStrParamArray[3]; | 116 | pwdStr = conStrParamArray[3]; |
100 | } else { | 117 | } else { |
... | @@ -107,17 +124,23 @@ public class OraMonRESTgetData extends HttpServlet { | ... | @@ -107,17 +124,23 @@ public class OraMonRESTgetData extends HttpServlet { |
107 | monitor = Registry.findOrCreate(conStr, usrStr, pwdStr); | 124 | monitor = Registry.findOrCreate(conStr, usrStr, pwdStr); |
108 | } | 125 | } |
109 | 126 | ||
127 | String pdbName = null; | ||
128 | if(request.getParameterMap().containsKey("pdbName")) { | ||
129 | String temp = request.getParameter("pdbName"); | ||
130 | if (!temp.isEmpty()) pdbName = temp; | ||
131 | } | ||
132 | |||
110 | if(monitor != null) { | 133 | if(monitor != null) { |
111 | // Call getData() | 134 | // Call getData() |
112 | boolean didUpdate = monitor.getData(age); | 135 | boolean didUpdate = monitor.getData(age,pdbName); |
113 | String dbName = monitor.getDBName(); | 136 | String dbName = monitor.getFriendlyName(pdbName); |
114 | if(didUpdate) { | 137 | if(didUpdate) { |
115 | sb.append("{\"error\":false,\"msg\":\"Sucessfully collected data on instance '" + dbName + "'\""); | 138 | sb.append("{\"error\":false,\"msg\":\"Sucessfully collected data on '" + dbName + "'\""); |
116 | sb.append(",\"ms\":"+monitor.getLastRTms()+"}"); | 139 | sb.append(",\"ms\":"+monitor.getLastRTms()+"}"); |
117 | } else { | 140 | } else { |
118 | response.setStatus(HttpServletResponse.SC_ACCEPTED); | 141 | response.setStatus(HttpServletResponse.SC_ACCEPTED); |
119 | sb.append("{\"error\":false"); | 142 | sb.append("{\"error\":false"); |
120 | sb.append(",\"msg\":\"Data does not need to be updated on instance '" + dbName + "' either because another thread did concurrently update the monitor and we just waited for it to complete, or because the age (if) specified was higher than the monitors data age.\""); | 143 | sb.append(",\"msg\":\"Data does not need to be updated on '" + dbName + "' either because another thread did concurrently update the monitor and we just waited for it to complete, or because the age (if) specified was higher than the monitors data age.\""); |
121 | sb.append(",\"age\":"+monitor.getAgeTs()+"}"); | 144 | sb.append(",\"age\":"+monitor.getAgeTs()+"}"); |
122 | } | 145 | } |
123 | } else { | 146 | } else { | ... | ... |
This diff is collapsed.
Click to expand it.
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
LILOM Library/Notes.md
0 → 100644
1 | # Notes | ||
2 | |||
3 | ## PDB logic | ||
4 | |||
5 | Bytt approuch och tagit bort allt som tidigare fanns i PDB branchen och har mergat den med master (då den innehöll TNS koden). | ||
6 | |||
7 | Gamla tanken var att via en PDB klura ut vad CDB databasens conn sträng är, ansluta till den, och hämta data för alla PDBer istället och cacha detta i CDB objektet. | ||
8 | Hade funkat fint, förutom att det förutsätter att CDB och PDB har samma lyssnare, vilket de inte nödvändigtvist har. Jag kan inte klura ut vad lyssnaren ska vara till CDB. | ||
9 | |||
10 | Istället får det bli en lösning där användaren alltid anger CDB databasens conn sträng, men kan med en flagga välja att få ut en PDB's info istället. | ||
11 | |||
12 | Idag ser tex ett anrop ut så här: | ||
13 | |||
14 | GET /OraMonREST/getData?age=14&connectionString=jdbc%3Aoracle%3Athin%3A%40%2F%2Fu03634.kap.rsv.se%3A1526%2FDB1K12 | ||
15 | |||
16 | I detta kan vi lägga till en parameter, forPDB=DA1K001 tex och då returneras endast värden för den PDB'n. | ||
17 | På så sätt kommer anrop till flera olika PDB att hämtas från samma CDB data cache. | ||
18 | Anropet till CDB'n skulle kunna returnera en lista på alla PDBer också. | ||
19 | Ännu snyggare vore om en CDB kunde bryta ner graferna per PDB också ;) | ||
20 | |||
21 | SQL satser | ||
22 | |||
23 | select cdb from v$database; | ||
24 | Returnerar YES om databasen är en CDB (dvs Oracle 12 med CDB påslaget). Returnerar YES även på en PDB. | ||
25 | |||
26 | Views for PDB's | ||
27 | |||
28 | V_$CON_SYSSTAT | ||
29 | V_$CON_SYSTEM_WAIT_CLASS | ||
30 | V_$CON_SYSTEM_EVENT | ||
31 | V_$CON_SYS_TIME_MODEL | ||
32 | |||
33 | Can be checked with a select like | ||
34 | select view_name from all_views where view_name like 'V_$CON_%'; | ||
35 | |||
36 | Slå samman con_id med statname | ||
37 | select systimestamp, name || con_id, value from V$CON_SYSSTAT; | ||
38 | |||
39 | 2018-03-28 | ||
40 | Första versionen med PDB stöd. Behövs mer tester. | ||
41 | |||
42 | PDB CPU: 11.056953715796771 | ||
43 | CDB CPU: 11.204673034978592 | ||
44 | DA1K001: 11.084891829252536 | ||
45 | DA1K002: 55.75905904774211 | ||
46 | TOTAL : 66.84395087699465 | ||
47 | |||
48 | Exemplet ovan är med ett delta på 60 sekunder, PDB går direkt mot PDB con string, CDB direkt mot CDB och DA räknarna är från denna CDB. | ||
49 | DA1K002 är på samma CDB, och getCPUPercent() ovan returnerar av någon anledning att den tar 55% cpu när hela CDB bara tar 11.2 vilket känns fel. | ||
50 | Det är bara DA1K001 som jobbar. Nedan från samma mätning fast Logical IO per Second istället: | ||
51 | |||
52 | PDB LIO: 433961.7046663872 | ||
53 | CDB LIO: 433532.02901594585 | ||
54 | DA1K001: 435343.22211814864 | ||
55 | DA1K002: 9.075934239850135 | ||
56 | TOTAL : 435352.2980523885 | ||
57 | |||
58 | Här känns alla värden rätt. Får göra klart GUI bitarna och se hur monitorerna beteer sig under längre tid. | ||
59 | |||
60 | När jag kört ett tag i graph läget nu på en PDB via CDB, ser jag även konstiga värden på mycket annat. Cache Hit Ratio på 1200%, negativa värden på flera räknare, mm. | ||
61 | GUI delarna lirar inte riktigt heller, getMetrics ger en 500 och en NullPointer (beror på att pdbName skickas alltid, null om den inte ska användas, och det funkar | ||
62 | inte i alla metoder i OraMon.java klassen). Anger man en PDB i OraMon.jsp så blir det HTTP 0 status?? på getData och getMetrics knapparna. | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -83,4 +83,17 @@ class Collector { | ... | @@ -83,4 +83,17 @@ class Collector { |
83 | else | 83 | else |
84 | return 0; | 84 | return 0; |
85 | } | 85 | } |
86 | |||
87 | public double getSeconds(String name) throws Throwable { | ||
88 | LongDelta myDelta = null; | ||
89 | for(int x = 0; x<list.size() && myDelta == null; x++) { | ||
90 | if(name.equals(list.get(x).name)) { | ||
91 | myDelta = list.get(x); | ||
92 | } | ||
93 | } | ||
94 | if(myDelta != null) | ||
95 | return myDelta.getSeconds(); | ||
96 | else | ||
97 | return 0; | ||
98 | } | ||
86 | } | 99 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -34,7 +34,7 @@ class LongDelta { | ... | @@ -34,7 +34,7 @@ class LongDelta { |
34 | update(value, timestamp, false); | 34 | update(value, timestamp, false); |
35 | } | 35 | } |
36 | 36 | ||
37 | public void update(Long value, Timestamp timestamp, boolean convert) { | 37 | public void update(long value, Timestamp timestamp, boolean convert) { |
38 | if(convert) value = value/1000; | 38 | if(convert) value = value/1000; |
39 | if(urProt) { | 39 | if(urProt) { |
40 | if(this.curValue != null && this.curValue > value) { | 40 | if(this.curValue != null && this.curValue > value) { | ... | ... |
This diff is collapsed.
Click to expand it.
... | @@ -11,13 +11,69 @@ public class TestRunner { | ... | @@ -11,13 +11,69 @@ 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 | testPDB(); | ||
19 | } | ||
20 | |||
21 | public static void testPDB() throws Throwable { | ||
22 | OraMon cdb = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DB1K12","dbsnmp","dbsnmp"); // CDB | ||
23 | OraMon pdb = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K001","dbsnmp","dbsnmp"); // PDB | ||
24 | |||
25 | int times = 5; | ||
26 | while(times-- > 0) { | ||
27 | cdb.getData(0, "DA1K001"); | ||
28 | pdb.getData(); | ||
29 | |||
30 | System.out.println("PDB CPU: " + pdb.getCPUPercent()); | ||
31 | System.out.println("CDB CPU: " + cdb.getCPUPercent()); | ||
32 | System.out.println("DA1K001: " + cdb.getCPUPercent(false, "DA1K001")); | ||
33 | System.out.println("DA1K002: " + cdb.getCPUPercent(false, "DA1K002")); | ||
34 | System.out.println("TOTAL : " + (cdb.getCPUPercent(false, "DA1K001") + cdb.getCPUPercent(false, "DA1K002"))); | ||
35 | |||
36 | System.out.println("PDB LIO: " + pdb.getLogicalReadsPerSecond()); | ||
37 | System.out.println("CDB LIO: " + cdb.getLogicalReadsPerSecond()); | ||
38 | System.out.println("DA1K001: " + cdb.getLogicalReadsPerSecond("DA1K001")); | ||
39 | System.out.println("DA1K002: " + cdb.getLogicalReadsPerSecond("DA1K002")); | ||
40 | System.out.println("TOTAL : " + (cdb.getLogicalReadsPerSecond("DA1K001") + cdb.getLogicalReadsPerSecond("DA1K002"))); | ||
41 | |||
42 | System.out.println("Sleeping 15s\n"); | ||
43 | Thread.sleep(60000); | ||
44 | } | ||
45 | cdb.close(); | ||
46 | pdb.close(); | ||
47 | } | ||
48 | |||
49 | public static void test1() throws Throwable { | ||
50 | OraMon mon = new OraMon("jdbc:oracle:thin:@//u02822.kap.rsv.se:1526/DB1K06","dbsnmp","dbsnmp"); // CDB | ||
51 | System.out.println("getData returned: " + mon.getData()); | ||
52 | System.out.println("getDatabaseName: " + mon.getDBName()); | ||
53 | } | ||
54 | |||
55 | public static void testTns() throws Throwable { | ||
56 | //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 | ||
57 | OraMon mon = new OraMon("jdbc:oracle:thin:@//u00153.kap.rsv.se:1526/DB1K01","dbsnmp","dbsnmp"); | ||
58 | System.out.println("getData returned: " + mon.getData()); | ||
59 | System.out.println("getDatabaseName: " + mon.getDBName()); | ||
60 | System.out.println("getServiceName: " + mon.getServiceName()); | ||
61 | System.out.println("getFriendlyName: " + mon.getFriendlyName()); | ||
62 | System.out.println("getConString: " + mon.getConString()); | ||
63 | System.out.println("getNumberOfCPUs: " + mon.getNumberOfCPUs()); | ||
64 | } | ||
65 | |||
66 | public static void runner1() throws Throwable { | ||
15 | // TODO Auto-generated method stub | 67 | // TODO Auto-generated method stub |
16 | 68 | ||
17 | //ArrayList<OraMon> oraList = new ArrayList<OraMon>(); | 69 | //ArrayList<OraMon> oraList = new ArrayList<OraMon>(); |
18 | ArrayList<OraMon> oraList = Registry.getList(); | 70 | ArrayList<OraMon> oraList = Registry.getList(); |
19 | 71 | ||
20 | OraMon mon1 = new OraMon("jdbc:oracle:thin:@uvp3dbkappkg:1550:VP1K03","dbsnmp","dbsnmp"); // SID eller Service Name format | 72 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@uvp3dbkappkg:1550:VP1K03","dbsnmp","dbsnmp"); // SID eller Service Name format |
73 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u00154.kap.rsv.se:1526/DB1K01","dbsnmp","dbsnmp"); | ||
74 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K001","dbsnmp","dbsnmp"); // PDB, CDB är DB1K12 | ||
75 | //OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DA1K002","dbsnmp","dbsnmp"); // Andra PDB på CDB DB1K12 | ||
76 | OraMon mon1 = new OraMon("jdbc:oracle:thin:@//u03634.kap.rsv.se:1526/DB1K12","dbsnmp","dbsnmp"); // PDB, CDB är DB1K12 | ||
21 | //OraMon mon2 = new OraMon("jdbc:oracle:thin:@host:port:sid","user","pass"); // SID format | 77 | //OraMon mon2 = new OraMon("jdbc:oracle:thin:@host:port:sid","user","pass"); // SID format |
22 | mon1.open(); | 78 | mon1.open(); |
23 | //mon2.open(); | 79 | //mon2.open(); | ... | ... |
-
Please register or sign in to post a comment