New feature to block/unblock an Oracle DB Monitor. Not implemented for
JMX Monitors yet.
Showing
6 changed files
with
53 additions
and
2 deletions
... | @@ -55,6 +55,16 @@ function getData(type, input, pdb) { | ... | @@ -55,6 +55,16 @@ function getData(type, input, pdb) { |
55 | client1.send(); | 55 | client1.send(); |
56 | } | 56 | } |
57 | 57 | ||
58 | function setBlocked(type, input, state) { | ||
59 | // Update the data | ||
60 | var client1 = new XMLHttpRequest(); | ||
61 | client1.onreadystatechange = dataHandler; | ||
62 | client1.open("GET", "" + type + "/getData?block=" + state + "&connectionString=" + encodeURIComponent(input)); | ||
63 | client1.setRequestHeader('Cache-Control', 'no-cache'); | ||
64 | client1.setRequestHeader('Pragma', 'no-cache'); | ||
65 | client1.send(); | ||
66 | } | ||
67 | |||
58 | function getMetrics(type, input, pdb) { | 68 | function getMetrics(type, input, pdb) { |
59 | // Get the metrics | 69 | // Get the metrics |
60 | var pdbAdd = ""; | 70 | var pdbAdd = ""; |
... | @@ -104,6 +114,7 @@ function dataHandler() { | ... | @@ -104,6 +114,7 @@ function dataHandler() { |
104 | <table> | 114 | <table> |
105 | <tr> | 115 | <tr> |
106 | <th>Name</th> | 116 | <th>Name</th> |
117 | <th>Instance</th> | ||
107 | <th>Connection String</th> | 118 | <th>Connection String</th> |
108 | <th>Data Calls</th> | 119 | <th>Data Calls</th> |
109 | <th>Success</th> | 120 | <th>Success</th> |
... | @@ -111,10 +122,12 @@ function dataHandler() { | ... | @@ -111,10 +122,12 @@ function dataHandler() { |
111 | <th>Last Exception</th> | 122 | <th>Last Exception</th> |
112 | <th>Age</th> | 123 | <th>Age</th> |
113 | <th>RT</th> | 124 | <th>RT</th> |
125 | <th>Blocked</th> | ||
114 | <th>Action</th> | 126 | <th>Action</th> |
115 | </tr> | 127 | </tr> |
116 | <% for (OraMon mon : se.lil.om.Registry.getList()) { %> | 128 | <% for (OraMon mon : se.lil.om.Registry.getList()) { %> |
117 | <tr> | 129 | <tr> |
130 | <td><%= mon.getFriendlyName() %></td> | ||
118 | <td><%= mon.getDBName() %></td> | 131 | <td><%= mon.getDBName() %></td> |
119 | <td><%= mon.getConString() %></td> | 132 | <td><%= mon.getConString() %></td> |
120 | <td><%= mon.getDataCalled() %></td> | 133 | <td><%= mon.getDataCalled() %></td> |
... | @@ -123,8 +136,10 @@ function dataHandler() { | ... | @@ -123,8 +136,10 @@ function dataHandler() { |
123 | <td><%= mon.getLastEx() %></td> | 136 | <td><%= mon.getLastEx() %></td> |
124 | <td><%= mon.getAgeTs() %>s</td> | 137 | <td><%= mon.getAgeTs() %>s</td> |
125 | <td><%= mon.getLastRTms() %>ms</td> | 138 | <td><%= mon.getLastRTms() %>ms</td> |
139 | <td><%= mon.getBlockedState() %></td> | ||
126 | <td> | 140 | <td> |
127 | <form method="POST"> | 141 | <form method="POST"> |
142 | <input id="blockButton" type="button" <%if(mon.getBlockedState()) { %>value="Unblock"<% } else { %>value="Block"<% } %> onClick="setBlocked('OraMonREST', '<%= mon.getConString() %>','<%= !mon.getBlockedState() %>')"> | ||
128 | <input type="submit" name="action" value="remove" > | 143 | <input type="submit" name="action" value="remove" > |
129 | <input type="hidden" name="omconstr" value="<%= mon.getConString() %>"> | 144 | <input type="hidden" name="omconstr" value="<%= mon.getConString() %>"> |
130 | <input type="button" value="graph" onClick="showGraph('viewOraMon','<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>',this.form.pdbName.value)"> | 145 | <input type="button" value="graph" onClick="showGraph('viewOraMon','<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>',this.form.pdbName.value)"> | ... | ... |
No preview for this file type
No preview for this file type
No preview for this file type
... | @@ -133,6 +133,27 @@ public class OraMonRESTgetData extends HttpServlet { | ... | @@ -133,6 +133,27 @@ public class OraMonRESTgetData extends HttpServlet { |
133 | } | 133 | } |
134 | 134 | ||
135 | if(monitor != null) { | 135 | if(monitor != null) { |
136 | if(request.getParameterMap().containsKey("block")) { | ||
137 | // Call setBlocked() | ||
138 | boolean blockedState = false; | ||
139 | try { | ||
140 | blockedState = Boolean.parseBoolean(request.getParameter("block")); | ||
141 | } catch (Exception e) { | ||
142 | response.setStatus(400); | ||
143 | response.getWriter().println("{\"error\":true,\"msg\":\"The specified block parameter is not a valid boolean\"}"); | ||
144 | return; | ||
145 | } | ||
146 | monitor.setBlockedState(blockedState); | ||
147 | if(blockedState == monitor.getBlockedState()) { | ||
148 | response.setStatus(200); | ||
149 | response.getWriter().println("{\"error\":false,\"msg\":\"The blocked state is now set to "+blockedState+"\"}"); | ||
150 | return; | ||
151 | } else { | ||
152 | response.setStatus(500); | ||
153 | response.getWriter().println("{\"error\":true,\"msg\":\"The blocked state could not be set to "+blockedState+"\"}"); | ||
154 | return; | ||
155 | } | ||
156 | } else { | ||
136 | // Call getData() | 157 | // Call getData() |
137 | boolean didUpdate = monitor.getData(age,pdbName); | 158 | boolean didUpdate = monitor.getData(age,pdbName); |
138 | String dbName = monitor.getFriendlyName(pdbName); | 159 | String dbName = monitor.getFriendlyName(pdbName); |
... | @@ -142,8 +163,10 @@ public class OraMonRESTgetData extends HttpServlet { | ... | @@ -142,8 +163,10 @@ public class OraMonRESTgetData extends HttpServlet { |
142 | } else { | 163 | } else { |
143 | response.setStatus(HttpServletResponse.SC_ACCEPTED); | 164 | response.setStatus(HttpServletResponse.SC_ACCEPTED); |
144 | sb.append("{\"error\":false"); | 165 | sb.append("{\"error\":false"); |
145 | 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.\""); | 166 | sb.append(",\"msg\":\"Data does not need to be updated on '" + dbName + "' either because it is blocked, 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.\""); |
146 | sb.append(",\"age\":"+monitor.getAgeTs()+"}"); | 167 | sb.append(",\"age\":"+monitor.getAgeTs()); |
168 | sb.append(",\"blocked\":"+monitor.getBlockedState()+"}"); | ||
169 | } | ||
147 | } | 170 | } |
148 | } else { | 171 | } else { |
149 | response.setStatus(HttpServletResponse.SC_NOT_FOUND); | 172 | response.setStatus(HttpServletResponse.SC_NOT_FOUND); | ... | ... |
... | @@ -35,6 +35,16 @@ public class OraMon { | ... | @@ -35,6 +35,16 @@ public class OraMon { |
35 | public static final String strNiwTime = " niwtime"; | 35 | public static final String strNiwTime = " niwtime"; |
36 | public static final String strSeparator = " "; | 36 | public static final String strSeparator = " "; |
37 | 37 | ||
38 | private boolean blocked = false; | ||
39 | |||
40 | public void setBlockedState(Boolean blockedState) { | ||
41 | this.blocked = blockedState; | ||
42 | } | ||
43 | |||
44 | public boolean getBlockedState() { | ||
45 | return this.blocked; | ||
46 | } | ||
47 | |||
38 | public int getNumPdbs() { | 48 | public int getNumPdbs() { |
39 | if(pdbSet != null) return pdbSet.size(); | 49 | if(pdbSet != null) return pdbSet.size(); |
40 | else return 0; | 50 | else return 0; |
... | @@ -325,6 +335,9 @@ public class OraMon { | ... | @@ -325,6 +335,9 @@ public class OraMon { |
325 | Throwable lastEx = null; | 335 | Throwable lastEx = null; |
326 | 336 | ||
327 | public boolean getData(long ageTs, String pdbName) throws Throwable { | 337 | public boolean getData(long ageTs, String pdbName) throws Throwable { |
338 | //Check if we are blocked. If we are, just return with false telling the caller we did not update. | ||
339 | if(this.blocked) return false; | ||
340 | |||
328 | //Check age (unless pdbName was set for the first time, in that case we need to discard the cached data) | 341 | //Check age (unless pdbName was set for the first time, in that case we need to discard the cached data) |
329 | if(getPdbs == false && pdbName != null) { | 342 | if(getPdbs == false && pdbName != null) { |
330 | getPdbs = true; | 343 | getPdbs = true; | ... | ... |
-
Please register or sign in to post a comment