Commit 2141767f 2141767f01f49b0b8ac4fafd4dc11adbdf8fdc12 by Christian Gerdes

Stöd för att köras direkt från Eclipse med en Tomcat 7

Viss debug och loggning av negativa värden, se Notes.md
1 parent 34b74092
...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
3 <name>JavaMonWeb</name> 3 <name>JavaMonWeb</name>
4 <comment></comment> 4 <comment></comment>
5 <projects> 5 <projects>
6 <project>LILJM Library</project>
7 <project>LILOM Library</project>
6 </projects> 8 </projects>
7 <buildSpec> 9 <buildSpec>
8 <buildCommand> 10 <buildCommand>
......
...@@ -49,7 +49,7 @@ function getData(type, input, pdb) { ...@@ -49,7 +49,7 @@ function getData(type, input, pdb) {
49 if(pdb != "" && pdb != null) pdbAdd = "&pdbName=" + pdb; 49 if(pdb != "" && pdb != null) pdbAdd = "&pdbName=" + pdb;
50 var client1 = new XMLHttpRequest(); 50 var client1 = new XMLHttpRequest();
51 client1.onreadystatechange = dataHandler; 51 client1.onreadystatechange = dataHandler;
52 client1.open("GET", "/" + type + "/getData?age=14" + pdbAdd + "&connectionString=" + encodeURIComponent(input)); 52 client1.open("GET", "" + type + "/getData?age=14" + pdbAdd + "&connectionString=" + encodeURIComponent(input));
53 client1.setRequestHeader('Cache-Control', 'no-cache'); 53 client1.setRequestHeader('Cache-Control', 'no-cache');
54 client1.setRequestHeader('Pragma', 'no-cache'); 54 client1.setRequestHeader('Pragma', 'no-cache');
55 client1.send(); 55 client1.send();
...@@ -61,12 +61,19 @@ function getMetrics(type, input, pdb) { ...@@ -61,12 +61,19 @@ function getMetrics(type, input, pdb) {
61 if(pdb != "" && pdb != null) pdbAdd = "pdbName=" + pdb + "&"; 61 if(pdb != "" && pdb != null) pdbAdd = "pdbName=" + pdb + "&";
62 var client2 = new XMLHttpRequest(); 62 var client2 = new XMLHttpRequest();
63 client2.onreadystatechange = metricsHandler; 63 client2.onreadystatechange = metricsHandler;
64 client2.open("GET", "/" + type + "/getMetrics?" + pdbAdd + "connectionString=" + encodeURIComponent(input)); 64 client2.open("GET", "" + type + "/getMetrics?" + pdbAdd + "connectionString=" + encodeURIComponent(input));
65 client2.setRequestHeader('Cache-Control', 'no-cache'); 65 client2.setRequestHeader('Cache-Control', 'no-cache');
66 client2.setRequestHeader('Pragma', 'no-cache'); 66 client2.setRequestHeader('Pragma', 'no-cache');
67 client2.send(); 67 client2.send();
68 } 68 }
69 69
70 function showGraph(type, input, pdb) {
71 // Get the metrics
72 var pdbAdd = "";
73 if(pdb != "" && pdb != null) pdbAdd = "&pdbName=" + pdb + "";
74 window.open(type + '.html?' + input + pdbAdd);
75 }
76
70 function metricsHandler() { 77 function metricsHandler() {
71 if (this.readyState == 4) { 78 if (this.readyState == 4) {
72 window.alert("HTTP " + this.status + "\n\n" + this.responseText); 79 window.alert("HTTP " + this.status + "\n\n" + this.responseText);
...@@ -120,7 +127,7 @@ function dataHandler() { ...@@ -120,7 +127,7 @@ function dataHandler() {
120 <form method="POST"> 127 <form method="POST">
121 <input type="submit" name="action" value="remove" > 128 <input type="submit" name="action" value="remove" >
122 <input type="hidden" name="omconstr" value="<%= mon.getConString() %>"> 129 <input type="hidden" name="omconstr" value="<%= mon.getConString() %>">
123 <input type="button" value="graph" onClick="window.open('/viewOraMon.html?<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>')"> 130 <input type="button" value="graph" onClick="showGraph('viewOraMon','<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>',this.form.pdbName.value)">
124 <input id="getDataButton" type="button" value="getData" onClick="getData('OraMonREST', '<%= mon.getConString() %>',this.form.pdbName.value)"> 131 <input id="getDataButton" type="button" value="getData" onClick="getData('OraMonREST', '<%= mon.getConString() %>',this.form.pdbName.value)">
125 <input id="getMetricsButton" type="button" value="getMetrics" onClick="getMetrics('OraMonREST', '<%= mon.getConString() %>',this.form.pdbName.value)"> 132 <input id="getMetricsButton" type="button" value="getMetrics" onClick="getMetrics('OraMonREST', '<%= mon.getConString() %>',this.form.pdbName.value)">
126 <input id="pdbName" name="pdbName" size="10"> 133 <input id="pdbName" name="pdbName" size="10">
......
1 <?xml version="1.0" encoding="UTF-8"?>
2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
3 <display-name>JavaMonWeb</display-name>
4 <welcome-file-list>
5 <welcome-file>OraMon.jsp</welcome-file>
6 </welcome-file-list>
7 </web-app>
...\ No newline at end of file ...\ No newline at end of file
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
90 statusP.innerHTML = "Updating..."; 90 statusP.innerHTML = "Updating...";
91 var client1 = new XMLHttpRequest(); 91 var client1 = new XMLHttpRequest();
92 client1.onreadystatechange = handler1; 92 client1.onreadystatechange = handler1;
93 client1.open("GET", "/JmxMonREST/getData?age=14&connectionString=" + location.search.substring(1)); 93 client1.open("GET", "JmxMonREST/getData?age=14&connectionString=" + location.search.substring(1));
94 client1.setRequestHeader('Cache-Control', 'no-cache'); 94 client1.setRequestHeader('Cache-Control', 'no-cache');
95 client1.setRequestHeader('Pragma', 'no-cache'); 95 client1.setRequestHeader('Pragma', 'no-cache');
96 client1.send(); 96 client1.send();
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
106 // Get the metrics 106 // Get the metrics
107 var client2 = new XMLHttpRequest(); 107 var client2 = new XMLHttpRequest();
108 client2.onreadystatechange = handler2; 108 client2.onreadystatechange = handler2;
109 client2.open("GET", "/JmxMonREST/getMetrics?connectionString=" + location.search.substring(1)); 109 client2.open("GET", "JmxMonREST/getMetrics?connectionString=" + location.search.substring(1));
110 client2.setRequestHeader('Cache-Control', 'no-cache'); 110 client2.setRequestHeader('Cache-Control', 'no-cache');
111 client2.setRequestHeader('Pragma', 'no-cache'); 111 client2.setRequestHeader('Pragma', 'no-cache');
112 client2.send(); 112 client2.send();
......
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
90 statusP.innerHTML = "Updating..."; 90 statusP.innerHTML = "Updating...";
91 var client1 = new XMLHttpRequest(); 91 var client1 = new XMLHttpRequest();
92 client1.onreadystatechange = handler1; 92 client1.onreadystatechange = handler1;
93 client1.open("GET", "/OraMonREST/getData?age=14&connectionString=" + location.search.substring(1)); 93 client1.open("GET", "OraMonREST/getData?age=14&connectionString=" + location.search.substring(1));
94 client1.setRequestHeader('Cache-Control', 'no-cache'); 94 client1.setRequestHeader('Cache-Control', 'no-cache');
95 client1.setRequestHeader('Pragma', 'no-cache'); 95 client1.setRequestHeader('Pragma', 'no-cache');
96 client1.send(); 96 client1.send();
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
106 // Get the metrics 106 // Get the metrics
107 var client2 = new XMLHttpRequest(); 107 var client2 = new XMLHttpRequest();
108 client2.onreadystatechange = handler2; 108 client2.onreadystatechange = handler2;
109 client2.open("GET", "/OraMonREST/getMetrics?connectionString=" + location.search.substring(1)); 109 client2.open("GET", "OraMonREST/getMetrics?connectionString=" + location.search.substring(1));
110 client2.setRequestHeader('Cache-Control', 'no-cache'); 110 client2.setRequestHeader('Cache-Control', 'no-cache');
111 client2.setRequestHeader('Pragma', 'no-cache'); 111 client2.setRequestHeader('Pragma', 'no-cache');
112 client2.send(); 112 client2.send();
......
...@@ -60,3 +60,9 @@ Här känns alla värden rätt. Får göra klart GUI bitarna och se hur monitore ...@@ -60,3 +60,9 @@ Här känns alla värden rätt. Får göra klart GUI bitarna och se hur monitore
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. 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 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. 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.
63
64 2018-05-02
65
66 Lyckades köra JavaMonWeb i Debug läge med Tomcat 7 local server. Skapade en sanityCheck() metod med break points så jag kan debugga när vissa räknare blir negativa.
67 Dock svårt att hitta rätt LongDelta objekt, eftersom det finns över 1000 i listan i random ordning. Behöver spara undan det nånstans eller breaka inne i en LongDelta metod istället.
68 Checkar in detta i alla fall så länge.
......
...@@ -5,10 +5,12 @@ import java.util.HashSet; ...@@ -5,10 +5,12 @@ import java.util.HashSet;
5 import java.util.Properties; 5 import java.util.Properties;
6 import java.util.concurrent.locks.Lock; 6 import java.util.concurrent.locks.Lock;
7 import java.util.concurrent.locks.ReentrantLock; 7 import java.util.concurrent.locks.ReentrantLock;
8 import java.util.logging.Logger;
8 import java.util.regex.Matcher; 9 import java.util.regex.Matcher;
9 import java.util.regex.Pattern; 10 import java.util.regex.Pattern;
10 11
11 public class OraMon { 12 public class OraMon {
13 private final static Logger LOGGER = Logger.getLogger(OraMon.class.getName());
12 Connection conn = null; 14 Connection conn = null;
13 String conString = "jdbc:oracle:thin:@//hostname:1521/SID"; 15 String conString = "jdbc:oracle:thin:@//hostname:1521/SID";
14 String conUser = "system"; 16 String conUser = "system";
...@@ -424,6 +426,9 @@ public class OraMon { ...@@ -424,6 +426,9 @@ public class OraMon {
424 } 426 }
425 427
426 stmt.close(); 428 stmt.close();
429
430 sanityCheck(pdbName);
431
427 getDataSucess++; 432 getDataSucess++;
428 lastFetchTSns = System.nanoTime(); 433 lastFetchTSns = System.nanoTime();
429 lastRTns = lastFetchTSns - startTSns; 434 lastRTns = lastFetchTSns - startTSns;
...@@ -447,6 +452,30 @@ public class OraMon { ...@@ -447,6 +452,30 @@ public class OraMon {
447 // End thread safe 452 // End thread safe
448 } 453 }
449 454
455 public void sanityCheck(String pdbName) throws Throwable {
456 String prefix = getFriendlyName(pdbName);
457 if(getBufferCacheHitRatioPercent(pdbName) < 0)
458 LOGGER.warning(prefix + " getBufferCacheHitRatioPercent" + " has negative delta");
459 if(getLogicalReadsPerSecond(pdbName) < 0)
460 LOGGER.warning(prefix + " getLogicalReadsPerSecond" + " has negative delta");
461 if(getCPUTimePerSecond(pdbName) < 0)
462 LOGGER.warning(prefix + " getCPUTimePerSecond" + " has negative delta");
463 if(getCacheHitRatioPercent(pdbName) < 0)
464 LOGGER.warning(prefix + " getCacheHitRatioPercent" + " has negative delta");
465 if(getCPUTimePerSecond(pdbName) < 0)
466 LOGGER.warning(prefix + " getCPUTimePerSecond" + " has negative delta");
467 if(getPerSecondValue("execute count",pdbName) < 0)
468 LOGGER.warning(prefix + " getPerSecondValue(execute count)" + " has negative delta");
469 if(getPerSecondValue("consistent gets",pdbName) < 0)
470 LOGGER.warning(prefix + " getPerSecondValue(consistent gets)" + " has negative delta");
471 if(getPerSecondValue("physical reads",pdbName) < 0)
472 LOGGER.warning(prefix + " getPerSecondValue(physical reads)" + " has negative delta");
473 if(getPerSecondValue("non-idle wait time",pdbName) < 0)
474 LOGGER.warning(prefix + " getPerSecondValue(non-idle wait time)" + " has negative delta");
475 if(getPerSecondValue("user commits",pdbName) < 0)
476 LOGGER.warning(prefix + " getPerSecondValue(user commits)" + " has negative delta");
477 }
478
450 public Throwable getLastEx() { 479 public Throwable getLastEx() {
451 return lastEx; 480 return lastEx;
452 } 481 }
......