Commit 21aac603 21aac6038a239c9b8422c7d264a911b9bf70be20 by Christian Gerdes

Partially working PDB support. Some bugs left to fix.

1 parent 431a092d
...@@ -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
...@@ -124,10 +124,16 @@ public class OraMonRESTgetData extends HttpServlet { ...@@ -124,10 +124,16 @@ public class OraMonRESTgetData extends HttpServlet {
124 monitor = Registry.findOrCreate(conStr, usrStr, pwdStr); 124 monitor = Registry.findOrCreate(conStr, usrStr, pwdStr);
125 } 125 }
126 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
127 if(monitor != null) { 133 if(monitor != null) {
128 // Call getData() 134 // Call getData()
129 boolean didUpdate = monitor.getData(age); 135 boolean didUpdate = monitor.getData(age,pdbName);
130 String dbName = monitor.getFriendlyName(); 136 String dbName = monitor.getFriendlyName(pdbName);
131 if(didUpdate) { 137 if(didUpdate) {
132 sb.append("{\"error\":false,\"msg\":\"Sucessfully collected data on '" + dbName + "'\""); 138 sb.append("{\"error\":false,\"msg\":\"Sucessfully collected data on '" + dbName + "'\"");
133 sb.append(",\"ms\":"+monitor.getLastRTms()+"}"); 139 sb.append(",\"ms\":"+monitor.getLastRTms()+"}");
......
1 1
2 2
3 import java.io.IOException; 3 import java.io.IOException;
4 import java.util.ArrayList;
5 4
6 import javax.servlet.ServletException; 5 import javax.servlet.ServletException;
7 import javax.servlet.annotation.WebServlet; 6 import javax.servlet.annotation.WebServlet;
...@@ -32,13 +31,13 @@ public class OraMonRESTgetMetrics extends HttpServlet { ...@@ -32,13 +31,13 @@ public class OraMonRESTgetMetrics extends HttpServlet {
32 */ 31 */
33 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 32 protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
34 response.setContentType("application/json"); 33 response.setContentType("application/json");
34 OraMon monitor = null;
35 try { 35 try {
36 StringBuffer sb = new StringBuffer(); 36 StringBuffer sb = new StringBuffer();
37 ArrayList<OraMon> list = Registry.getList();
38 37
39 if(request.getParameterMap().containsKey("connectionString")) { 38 if(request.getParameterMap().containsKey("connectionString")) {
40 // We have a connection string, find the monitor and report only on that monitor 39 // We have a connection string, find the monitor and report only on that monitor
41 OraMon monitor = null; 40
42 if(request.getParameter("connectionString").startsWith("jdbc:oracle")) { 41 if(request.getParameter("connectionString").startsWith("jdbc:oracle")) {
43 // Full con string 42 // Full con string
44 String[] shortConArray = request.getParameter("connectionString").split("@"); 43 String[] shortConArray = request.getParameter("connectionString").split("@");
...@@ -107,59 +106,60 @@ public class OraMonRESTgetMetrics extends HttpServlet { ...@@ -107,59 +106,60 @@ public class OraMonRESTgetMetrics extends HttpServlet {
107 conStr = "jdbc:oracle:thin:@" + conStrParamArray[0] + ":" + conStrParamArray[1] + ":" + conStrParamArray[2]; 106 conStr = "jdbc:oracle:thin:@" + conStrParamArray[0] + ":" + conStrParamArray[1] + ":" + conStrParamArray[2];
108 } 107 }
109 monitor = Registry.find(conStr); 108 monitor = Registry.find(conStr);
109 }
110 }
111
110 if(monitor == null) { 112 if(monitor == null) {
111 // Not found, create it 113 // Not found, response with 404
112 response.setStatus(HttpServletResponse.SC_NOT_FOUND); 114 response.setStatus(HttpServletResponse.SC_NOT_FOUND);
113 response.getWriter().println("{\"error\":true,\"msg\":\"Can not find a monitor with connection string "+request.getParameter("connectionString")+"\"}"); 115 response.getWriter().println("{\"error\":true,\"msg\":\"Can not find a monitor with connection string "+request.getParameter("connectionString")+"\"}");
114 return; 116 return;
115 } 117 }
116 }
117 118
118 // Set this monitor to the only one on the list 119 String pdbName = null;
119 list = new ArrayList<OraMon>(); 120 if(request.getParameterMap().containsKey("pdbName")) {
120 list.add(monitor); 121 String temp = request.getParameter("pdbName");
122 if (!temp.isEmpty()) pdbName = temp;
121 } 123 }
122 124
123 // Loop over all monitors and output a Json array with the default set of metrics 125 // Write out the monitors data
124 126 sb.append("{\"name\":\"" + monitor.getFriendlyName(pdbName) + "\",\"error\":false,\"nvarray\":");
125 for (OraMon item : list) {
126 sb.append("{\"name\":\"" + item.getFriendlyName() + "\",\"error\":false,\"nvarray\":");
127 sb.append("["); 127 sb.append("[");
128 128
129 129
130 sb.append("{\"name\":\"Cpu Usage (%)\",\"value\":" + item.getCPUPercent() + "}"); 130 sb.append("{\"name\":\"Cpu Usage (%)\",\"value\":" + monitor.getCPUPercent(pdbName) + "}");
131 sb.append(",{\"name\":\"Logical Reads (#/s)\",\"value\":" + item.getLogicalReadsPerSecond() + "}"); 131 sb.append(",{\"name\":\"Logical Reads (#/s)\",\"value\":" + monitor.getLogicalReadsPerSecond(pdbName) + "}");
132 sb.append(",{\"name\":\"Executes (#/s)\",\"value\":" + item.getPerSecondValue("execute count") + "}"); 132 sb.append(",{\"name\":\"Executes (#/s)\",\"value\":" + monitor.getPerSecondValue("execute count",pdbName) + "}");
133 sb.append(",{\"name\":\"User Calls (#/s)\",\"value\":" + item.getPerSecondValue("user calls") + "}"); 133 sb.append(",{\"name\":\"User Calls (#/s)\",\"value\":" + monitor.getPerSecondValue("user calls",pdbName) + "}");
134 sb.append(",{\"name\":\"Cache Hit Ratio (%)\",\"value\":" + item.getCacheHitRatioPercent() + "}"); 134 sb.append(",{\"name\":\"Cache Hit Ratio (%)\",\"value\":" + monitor.getCacheHitRatioPercent(pdbName) + "}");
135 sb.append(",{\"name\":\"Redo Size (#/s)\",\"value\":" + item.getPerSecondValue("redo size") + "}"); 135 sb.append(",{\"name\":\"Redo Size (#/s)\",\"value\":" + monitor.getPerSecondValue("redo size",pdbName) + "}");
136 136
137 sb.append(",{\"name\":\"OS Busy (%)\",\"value\":" + item.getOsBusyPercent() + "}"); 137 sb.append(",{\"name\":\"OS Busy (%)\",\"value\":" + monitor.getOsBusyPercent() + "}");
138 sb.append(",{\"name\":\"OS Load (#)\",\"value\":" + item.getOsLoad() + "}"); 138 sb.append(",{\"name\":\"OS Load (#)\",\"value\":" + monitor.getOsLoad() + "}");
139 sb.append(",{\"name\":\"OS Page In (KB/s)\",\"value\":" + item.getPerSecondValue("VM_IN_BYTES", OraMon.OSSTAT)/1024 + "}"); 139 sb.append(",{\"name\":\"OS Page In (KB/s)\",\"value\":" + monitor.getPerSecondValue("VM_IN_BYTES", OraMon.OSSTAT)/1024 + "}");
140 sb.append(",{\"name\":\"OS Page Out (KB/s)\",\"value\":" + item.getPerSecondValue("VM_OUT_BYTES", OraMon.OSSTAT)/1024 + "}"); 140 sb.append(",{\"name\":\"OS Page Out (KB/s)\",\"value\":" + monitor.getPerSecondValue("VM_OUT_BYTES", OraMon.OSSTAT)/1024 + "}");
141 sb.append(",{\"name\":\"OS Load per Cpu (#)\",\"value\":" + item.getOsLoadPerCPU() + "}"); 141 sb.append(",{\"name\":\"OS Load per Cpu (#)\",\"value\":" + monitor.getOsLoadPerCPU() + "}");
142 142
143 sb.append(",{\"name\":\"Consistent Gets (#/s)\",\"value\":" + item.getPerSecondValue("consistent gets") + "}"); 143 sb.append(",{\"name\":\"Consistent Gets (#/s)\",\"value\":" + monitor.getPerSecondValue("consistent gets",pdbName) + "}");
144 sb.append(",{\"name\":\"DB Block Gets (#/s)\",\"value\":" + item.getPerSecondValue("db block gets") + "}"); 144 sb.append(",{\"name\":\"DB Block Gets (#/s)\",\"value\":" + monitor.getPerSecondValue("db block gets",pdbName) + "}");
145 145
146 sb.append(",{\"name\":\"Buffer Cache Hit Ratio (%)\",\"value\":" + item.getBufferCacheHitRatioPercent() + "}"); 146 sb.append(",{\"name\":\"Buffer Cache Hit Ratio (%)\",\"value\":" + monitor.getBufferCacheHitRatioPercent(pdbName) + "}");
147 sb.append(",{\"name\":\"DB Block Changes (#/s)\",\"value\":" + item.getPerSecondValue("db block changes") + "}"); 147 sb.append(",{\"name\":\"DB Block Changes (#/s)\",\"value\":" + monitor.getPerSecondValue("db block changes",pdbName) + "}");
148 148
149 sb.append(",{\"name\":\"Physical Reads (#/s)\",\"value\":" + item.getPerSecondValue("physical reads") + "}"); 149 sb.append(",{\"name\":\"Physical Reads (#/s)\",\"value\":" + monitor.getPerSecondValue("physical reads",pdbName) + "}");
150 sb.append(",{\"name\":\"Physical Writes (#/s)\",\"value\":" + item.getPerSecondValue("physical writes") + "}"); 150 sb.append(",{\"name\":\"Physical Writes (#/s)\",\"value\":" + monitor.getPerSecondValue("physical writes",pdbName) + "}");
151 sb.append(",{\"name\":\"Redo Writes (#/s)\",\"value\":" + item.getPerSecondValue("redo writes") + "}"); 151 sb.append(",{\"name\":\"Redo Writes (#/s)\",\"value\":" + monitor.getPerSecondValue("redo writes",pdbName) + "}");
152 sb.append(",{\"name\":\"Non-idle Wait Time (ms/s)\",\"value\":" + item.getPerSecondValue("non-idle wait time") + "}"); 152 sb.append(",{\"name\":\"Non-idle Wait Time (ms/s)\",\"value\":" + monitor.getPerSecondValue("non-idle wait time",pdbName) + "}");
153 sb.append(",{\"name\":\"File I/O Wait Time (ms/s)\",\"value\":" + item.getPerSecondValue("file io wait time") + "}"); 153 sb.append(",{\"name\":\"File I/O Wait Time (ms/s)\",\"value\":" + monitor.getPerSecondValue("file io wait time",pdbName) + "}");
154
155 sb.append(",{\"name\":\"User Commits (#/s)\",\"value\":" + monitor.getPerSecondValue("user commits",pdbName) + "}");
156 sb.append(",{\"name\":\"User Rollbacks (#/s)\",\"value\":" + monitor.getPerSecondValue("user rollbacks",pdbName) + "}");
157 sb.append(",{\"name\":\"Parse Count Total (#/s)\",\"value\":" + monitor.getPerSecondValue("parse count (total)",pdbName) + "}");
158 sb.append(",{\"name\":\"Parse Count Hard (#/s)\",\"value\":" + monitor.getPerSecondValue("parse count (hard)",pdbName) + "}");
159 sb.append(",{\"name\":\"Cpu Usage xNIWT (%)\",\"value\":" + monitor.getCPUPercent(true,pdbName) + "}");
160 sb.append(",{\"name\":\"Cpu Time (us/s)\",\"value\":" + monitor.getCPUTimePerSecond(pdbName) + "}");
161 sb.append(",{\"name\":\"Cpus (#)\",\"value\":" + monitor.getNumberOfCPUs() + "}");
154 162
155 sb.append(",{\"name\":\"User Commits (#/s)\",\"value\":" + item.getPerSecondValue("user commits") + "}");
156 sb.append(",{\"name\":\"User Rollbacks (#/s)\",\"value\":" + item.getPerSecondValue("user rollbacks") + "}");
157 sb.append(",{\"name\":\"Parse Count Total (#/s)\",\"value\":" + item.getPerSecondValue("parse count (total)") + "}");
158 sb.append(",{\"name\":\"Parse Count Hard (#/s)\",\"value\":" + item.getPerSecondValue("parse count (hard)") + "}");
159 sb.append(",{\"name\":\"Cpu Usage xNIWT (%)\",\"value\":" + item.getCPUPercent(true) + "}");
160 sb.append(",{\"name\":\"Cpu Time (us/s)\",\"value\":" + item.getCPUTimePerSecond() + "}");
161 sb.append(",{\"name\":\"Cpus (#)\",\"value\":" + item.getNumberOfCPUs() + "}");
162 }
163 sb.append("]}"); 163 sb.append("]}");
164 164
165 response.getWriter().println(sb.toString()); 165 response.getWriter().println(sb.toString());
......
...@@ -55,4 +55,8 @@ DA1K001: 435343.22211814864 ...@@ -55,4 +55,8 @@ DA1K001: 435343.22211814864
55 DA1K002: 9.075934239850135 55 DA1K002: 9.075934239850135
56 TOTAL : 435352.2980523885 56 TOTAL : 435352.2980523885
57 57
58 Här känns alla värden rätt.
...\ No newline at end of file ...\ No newline at end of file
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
......
1 package se.lil.om; 1 package se.lil.om;
2 2
3 import java.sql.*; 3 import java.sql.*;
4 import java.util.ArrayList; 4 import java.util.HashSet;
5 import java.util.HashMap;
6 import java.util.Properties; 5 import java.util.Properties;
7 import java.util.concurrent.locks.Lock; 6 import java.util.concurrent.locks.Lock;
8 import java.util.concurrent.locks.ReentrantLock; 7 import java.util.concurrent.locks.ReentrantLock;
...@@ -29,10 +28,21 @@ public class OraMon { ...@@ -29,10 +28,21 @@ public class OraMon {
29 boolean getPdbs = false; 28 boolean getPdbs = false;
30 Collector colPdbSysStat = null; 29 Collector colPdbSysStat = null;
31 Collector colPdbCPU = null; 30 Collector colPdbCPU = null;
31 HashSet<String> pdbSet = null;
32 public static final String strCpuTime = " cputime"; 32 public static final String strCpuTime = " cputime";
33 public static final String strNiwTime = " niwtime"; 33 public static final String strNiwTime = " niwtime";
34 public static final String strSeparator = " "; 34 public static final String strSeparator = " ";
35 35
36 public int getNumPdbs() {
37 if(pdbSet != null) return pdbSet.size();
38 else return 0;
39 }
40
41 public String[] getPdbArray() {
42 if(pdbSet != null) return (String[]) pdbSet.toArray();
43 else return null;
44 }
45
36 public int getDataCalled() { 46 public int getDataCalled() {
37 return getDataCalls; 47 return getDataCalls;
38 } 48 }
...@@ -150,6 +160,10 @@ public class OraMon { ...@@ -150,6 +160,10 @@ public class OraMon {
150 return getPerSecondValue(name, table, null); 160 return getPerSecondValue(name, table, null);
151 } 161 }
152 162
163 public double getPerSecondValue(String name, String pdbName) throws Throwable {
164 return getPerSecondValue(name, SYSSTAT, pdbName);
165 }
166
153 public double getPerSecondValue(String name, int table, String pdbName) throws Throwable { 167 public double getPerSecondValue(String name, int table, String pdbName) throws Throwable {
154 switch (table) { 168 switch (table) {
155 case OSSTAT: 169 case OSSTAT:
...@@ -170,11 +184,20 @@ public class OraMon { ...@@ -170,11 +184,20 @@ public class OraMon {
170 } 184 }
171 185
172 public String getFriendlyName() { 186 public String getFriendlyName() {
187 return getFriendlyName(null);
188 }
189
190 public String getFriendlyName(String pdbName) {
173 // Returns a friendly name of the database, either the service name from con string or the database name from the instance 191 // Returns a friendly name of the database, either the service name from con string or the database name from the instance
174 getServiceName(); 192 getServiceName();
193 if(pdbName != null) {
194 if(this.serviceName != null) return this.serviceName + ":" + pdbName;
195 else return this.dbName + ":" + pdbName;
196 } else {
175 if(this.serviceName != null) return this.serviceName; 197 if(this.serviceName != null) return this.serviceName;
176 else return this.dbName; 198 else return this.dbName;
177 } 199 }
200 }
178 201
179 public double getOsBusyPercent() throws Throwable { 202 public double getOsBusyPercent() throws Throwable {
180 double idle = getPerSecondValue("IDLE_TIME", OSSTAT); 203 double idle = getPerSecondValue("IDLE_TIME", OSSTAT);
...@@ -374,8 +397,12 @@ public class OraMon { ...@@ -374,8 +397,12 @@ public class OraMon {
374 if(colPdbCPU == null) colPdbCPU = new Collector(); 397 if(colPdbCPU == null) colPdbCPU = new Collector();
375 rset = stmt.executeQuery("select systimestamp, c.NAME, s.value as NIWT, t.value as DBCPU from V$CON_SYSSTAT s, V$CON_SYS_TIME_MODEL t, V$CONTAINERS c where s.CON_ID=t.CON_ID and s.CON_ID=c.CON_ID and s.name='non-idle wait time' and t.STAT_NAME='DB CPU'"); 398 rset = stmt.executeQuery("select systimestamp, c.NAME, s.value as NIWT, t.value as DBCPU from V$CON_SYSSTAT s, V$CON_SYS_TIME_MODEL t, V$CONTAINERS c where s.CON_ID=t.CON_ID and s.CON_ID=c.CON_ID and s.name='non-idle wait time' and t.STAT_NAME='DB CPU'");
376 while(rset.next()) { 399 while(rset.next()) {
377 colPdbCPU.updateValue(rset.getTimestamp(1), rset.getString(2) + strNiwTime, rset.getLong(3)); 400 Timestamp ts = rset.getTimestamp(1);
378 colPdbCPU.updateValue(rset.getTimestamp(1), rset.getString(2) + strCpuTime, rset.getLong(4)); 401 String name = rset.getString(2);
402 colPdbCPU.updateValue(ts, name + strNiwTime, rset.getLong(3));
403 colPdbCPU.updateValue(ts, name + strCpuTime, rset.getLong(4));
404 if(pdbSet == null) pdbSet = new HashSet<String>();
405 pdbSet.add(name);
379 } 406 }
380 rset.close(); 407 rset.close();
381 408
......