OraMon.jsp
7.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<%@page import="java.net.URLEncoder"%>
<%@page import="se.lil.om.Registry"%>
<%@page import="se.lil.om.OraMon"%>
<%@page import="se.lil.jm.JmxMon"%>
<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>OraMon Admin</title>
</head>
<body>
<%
// Handling of actions
boolean error = false;
String errMsg = "";
boolean info = false;
String infMsg = "";
if(request.getParameter("action") != null) {
if(request.getParameter("action").equals("remove")) {
if(request.getParameter("omconstr") != null && request.getParameter("omconstr").length() != 0) {
se.lil.om.Registry.remove(request.getParameter("omconstr"));
info = true;
infMsg = "Removed OraMon " + request.getParameter("omconstr");
}
if(request.getParameter("jmconstr") != null && request.getParameter("jmconstr").length() != 0) {
se.lil.jm.Registry.remove(request.getParameter("jmconstr"));
info = true;
infMsg = "Removed JmxMon " + request.getParameter("jmconstr");
}
}
}
%>
<% if(error) { %>
<div style="background: Salmon; padding: 10px;">Error: <%= errMsg %></div>
<% } %>
<% if(info) { %>
<div style="background: Aquamarine; padding: 10px;">Info: <%= infMsg %> <form><input type="submit" value="OK"></form></div>
<% } %>
<script type="text/javascript">
function getData(type, input, pdb) {
// Update the data
var pdbAdd = "";
if(pdb != "" && pdb != null) pdbAdd = "&pdbName=" + pdb;
var client1 = new XMLHttpRequest();
client1.onreadystatechange = dataHandler;
client1.open("GET", "" + type + "/getData?age=14" + pdbAdd + "&connectionString=" + encodeURIComponent(input));
client1.setRequestHeader('Cache-Control', 'no-cache');
client1.setRequestHeader('Pragma', 'no-cache');
client1.send();
}
function setBlocked(type, input, state) {
// Update the data
var client1 = new XMLHttpRequest();
client1.onreadystatechange = dataHandler;
client1.open("GET", "" + type + "/getData?block=" + state + "&connectionString=" + encodeURIComponent(input));
client1.setRequestHeader('Cache-Control', 'no-cache');
client1.setRequestHeader('Pragma', 'no-cache');
client1.send();
}
function getMetrics(type, input, pdb) {
// Get the metrics
var pdbAdd = "";
if(pdb != "" && pdb != null) pdbAdd = "pdbName=" + pdb + "&";
var client2 = new XMLHttpRequest();
client2.onreadystatechange = metricsHandler;
client2.open("GET", "" + type + "/getMetrics?" + pdbAdd + "connectionString=" + encodeURIComponent(input));
client2.setRequestHeader('Cache-Control', 'no-cache');
client2.setRequestHeader('Pragma', 'no-cache');
client2.send();
}
function showGraph(type, input, pdb) {
// Get the metrics
var pdbAdd = "";
if(pdb != "" && pdb != null) pdbAdd = "&pdbName=" + pdb + "";
window.open(type + '.html?' + input + pdbAdd);
}
function metricsHandler() {
if (this.readyState == 4) {
window.alert("HTTP " + this.status + "\n\n" + this.responseText);
}
}
function dataHandler() {
if (this.readyState == 4) {
window.alert("HTTP " + this.status + "\n\n" + this.responseText);
}
}
</script>
<h1>OraMon Web 1.1 with JmxMon</h1>
<h2>Status Oracle Monitors</h2>
<p>Number of monitors: <%= se.lil.om.Registry.getList().size() %></p>
<div title="Add Monitor" style="background: WhiteSmoke; padding: 10px;">
<form>
<table>
<tr><td>Connection String:</td><td><input id="addoradata" name="data" size="70"></td><td><input type="button" value="add" onClick="getData('OraMonREST', addoradata.value)"></td></tr>
</table>
</form>
</div>
<div style="background-color: LightSteelBlue; padding: 10px;">
<table>
<tr>
<th>Name</th>
<th>Instance</th>
<th>Connection String</th>
<th>Data Calls</th>
<th>Success</th>
<th>Failed</th>
<th>Last Exception</th>
<th>Age</th>
<th>RT</th>
<th>Blocked</th>
<th>Action</th>
</tr>
<% for (OraMon mon : se.lil.om.Registry.getList()) { %>
<tr>
<td><%= mon.getFriendlyName() %></td>
<td><%= mon.getDBName() %></td>
<td><%= mon.getConString() %></td>
<td><%= mon.getDataCalled() %></td>
<td><%= mon.getDataSucceeded() %></td>
<td><%= mon.getDataFailed() %></td>
<td><%= mon.getLastEx() %></td>
<td><%= mon.getAgeTs() %>s</td>
<td><%= mon.getLastRTms() %>ms</td>
<td><%= mon.getBlockedState() %></td>
<td>
<form method="POST">
<input id="blockButton" type="button" <%if(mon.getBlockedState()) { %>value="Unblock"<% } else { %>value="Block"<% } %> onClick="setBlocked('OraMonREST', '<%= mon.getConString() %>','<%= !mon.getBlockedState() %>')">
<input type="submit" name="action" value="remove" >
<input type="hidden" name="omconstr" value="<%= mon.getConString() %>">
<input type="button" value="graph" onClick="showGraph('viewOraMon','<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>',this.form.pdbName.value)">
<input id="getDataButton" type="button" value="getData" onClick="getData('OraMonREST', '<%= mon.getConString() %>',this.form.pdbName.value)">
<input id="getMetricsButton" type="button" value="getMetrics" onClick="getMetrics('OraMonREST', '<%= mon.getConString() %>',this.form.pdbName.value)">
<input id="pdbName" name="pdbName" size="10">
</form>
</td>
</tr>
<% } %>
</table>
</div>
<h2>Status JMX Monitors</h2>
<p>Number of monitors: <%= se.lil.jm.Registry.getList().size() %></p>
<div title="Add Monitor" style="background: WhiteSmoke; padding: 10px;">
<form>
<table>
<tr><td>Connection String:</td><td><input id="addjmxdata" name="data" size="70"></td><td><input type="button" value="add" onClick="getData('JmxMonREST', addjmxdata.value)"></td></tr>
</table>
</form>
</div>
<div style="background-color: LightSteelBlue; padding: 10px;">
<table>
<tr>
<th>Name</th>
<th>Connection String</th>
<th>Data Calls</th>
<th>Success</th>
<th>Failed</th>
<th>Last Exception</th>
<th>Age</th>
<th>RT</th>
<th>Action</th>
</tr>
<% for (JmxMon mon : se.lil.jm.Registry.getList()) { %>
<tr>
<td><%= mon.getServerName() %></td>
<td><%= mon.getConString() %></td>
<td><%= mon.getDataCalled() %></td>
<td><%= mon.getDataSucceeded() %></td>
<td><%= mon.getDataFailed() %></td>
<td><%= mon.getLastEx() %></td>
<td><%= mon.getAgeTs() %>s</td>
<td><%= mon.getLastRTms() %>ms</td>
<td>
<form method="POST">
<input type="submit" name="action" value="remove" >
<input type="hidden" name="jmconstr" value="<%= mon.getConString() %>">
<input type="button" value="graph" onClick="window.open('/viewJmxMon.html?<%= URLEncoder.encode(mon.getConString(), "UTF-8") %>')">
<input type="button" value="getData" onClick="getData('JmxMonREST', '<%= mon.getConString() %>')">
<input type="button" value="getMetrics" onClick="getMetrics('JmxMonREST', '<%= mon.getConString() %>')">
</form>
</td>
</tr>
<% } %>
</table>
</div>
</body>
</html>