-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathping.jsp
464 lines (410 loc) · 10.2 KB
/
ping.jsp
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.Connection"%>
<%@page import="newpackage.NewClass" %>
<body>
<%
String S1=request.getParameter("S1");
String b= request.getParameter("b");
String b1 =request.getParameter("b1");
String m=request.getParameter("m");
String site=new String("http://localhost:52948/WebApplication1/graph.jsp");
NewClass obj=new NewClass();
if("Test".equals(b))
{
try
{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/PingData", "PingPoller", "PingPoller");
PreparedStatement ps = con.prepareStatement("SELECT * FROM LINK_MASTER");
ResultSet rs = ps.executeQuery();
%>
<img src="loading.gif" style="width: 100px" style="height:100px">
<a>Processing...</a>
<h5>Click View Details-->Regular to check recent updates</h5>
<%
while(rs.next())
{
String link=rs.getString("LINK_ID");
String isp=rs.getString("ISP_NAME");
obj.Ping(S1,link,isp);
}
}
catch(Exception e)
{
}
}
else if("Stop".equals(b))
{
obj.Stop();
}
else if("Regular".equals(b1))
{
%>
<table align="center" top="30px" >
<h4 align="center" left="250px"><font><strong>PING</strong></font></h4>
<tr>
<tr bgcolor="#727272">
<th><b>LINK_ID</b></th>
<th><b>DOWNDATE</b></th>
<th><b>DOWNTIME</b></th>
<th><b>UPDATE</b></th>
<th><b>UPTIME</b></th>
<th><b>DURATION</b></th>
</tr><br>
<%
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/PingData", "PingPoller", "PingPoller");
Statement statement=con.createStatement();
String sql ="SELECT * FROM PING";
ResultSet resultSet = statement.executeQuery(sql);
while(resultSet.next()){
%>
<tr>
<td><%=resultSet.getString("link_id") %></td>
<td><%=resultSet.getString("down_date") %></td>
<td><%=resultSet.getString("down_time") %></td>
<td><%=resultSet.getString("up_date") %></td>
<td><%=resultSet.getString("up_time") %></td>
<td><%=resultSet.getString("duration") %></td>
</tr><br>
<%
}
} catch (Exception e)
{
e.printStackTrace();
}
}
else if("Graphical".equals(b1))
{
response.setStatus(response.SC_MOVED_TEMPORARILY);
response.setHeader("Location",site);
}
else if("Up details".equals(b1))
{
%>
<table align="center" top="30px" >
<h4 align="center" left="250px"><font><strong>Monthly Uptime Percent</strong></font></h4>
<tr>
<tr bgcolor="#727272">
<th><b>MONTH</b></th>
<th><b>ISP</b></th>
<th><b>UPTIME</b></th>
<th><b>UPTIME PERCENT</b></th>
</tr><br>
<%
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/PingData", "PingPoller", "PingPoller");
Statement statement=con.createStatement();
String sql ="SELECT * FROM PERCENTAGE_UPTIME";
ResultSet resultSet = statement.executeQuery(sql);
while(resultSet.next()){
%>
<tr>
<td><%=resultSet.getString("month") %></td>
<td><%=resultSet.getString("isp") %></td>
<td><%=resultSet.getString("uptime") %></td>
<td><%=resultSet.getString("uptime_percent") %></td>
</tr><br>
<%
}
} catch (Exception e) {
e.printStackTrace();
}
}
else if("Down details".equals(b1))
{
%>
<table align="center" top="30px" >
<h4 align="center" left="250px"><font><strong>Monthly View:Summary</strong></font></h4>
<tr>
<tr bgcolor="#727272">
<th><b>MONTH</b></th>
<th><b>ISP</b></th>
<th><b>LINK ID</b></th>
<th><b>TOTAL</b></th>
</tr><br>
<%
try{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/PingData", "PingPoller", "PingPoller");
Statement statement=con.createStatement();
String sql ="SELECT * FROM DOWNTIME_SUMMARY";
ResultSet resultSet = statement.executeQuery(sql);
while(resultSet.next()){
%>
<tr>
<td><%=resultSet.getString("month") %></td>
<td><%=resultSet.getString("isp") %></td>
<td><%=resultSet.getString("link_id") %></td>
<td><%=resultSet.getString("total") %></td>
</tr><br>
<%
}
} catch (Exception e) {
e.printStackTrace();
}
}
%>
</table>
</body>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PingPoller</title>
<style>
body{
margin:0;
padding: 20px;
background: url(datacenter.jpeg);
background-size:cover;
background-position:center;
font-family: oswald;
}
form{
backgroud-color:#000;
color:#fff;
top:30%;
left:20%;
position: absolute;
transform: translate(-50%,-50%);
padding: 0px;
font-size: 30px;
font-weight: bold;
}
input{
width: 100%;
border-radius:5px;
font-weight: bold;
margin-top:5px;
padding:10px;
font-size: 15px;
background:black;
color:#fff;
opacity: 0.65;
}
input [type="Submit"]
{
border: none;
outline: none;
}
input[type="Submit"]:hover
{
cursor: pointer;
background:#7dabf2;
color: #fff;
opacity: 0.8;
}
p{
font-size: 24px;
}
table{
top:60px;
position:relative;
left:200px;
background-color:#e1e7f2;
color:white;
opacity: 0.7;
}
th{
padding:10px;
font-weight:700;
text-decoration: underline;
border-bottom:1px solid black;
border-right:1px solid black;
margin:2px;
background: black;
opacity: 0.7;
}
h4{
transform:translate(200px,90px);
text-decoration:underline;
color:#fff;
}
td{
padding:10px;
border-bottom:1px solid black;
border-right:1px solid black;
margin:2px;
color:black;
}
select{
width:100%;
font-size:20px;
padding:10px;
background:#000;
color: #fff;
opacity: 0.65;
}
div ul{
list-style: none;
margin-top:5px;
font-size: 15px;
text-align: center;
margin-left: -20%;
font-family: oswald;
}
div ul li{
border: none;
outline: none;
padding:10px;
border-radius:5px;
font-weight: bold;
width: 91%;
background:#000;
color: #fff;
opacity: 0.65;
}
div ul li:hover{
cursor: pointer;
background:#7dabf2;
color: #fff;
opacity: 0.8;
}
div ul ul{
display: none;
margin-left:75%;
top: 190px;
position: absolute;
width: 67%;
}
div ul li:hover>ul{
display: block;
}
div ul ul ul{
margin-left:50%;
top:38px;
display: none;
position: absolute;
}
div ul ul li:hover>ul{
display: block;
}
div ul ul ul ul{
margin-left: 47%;
top:-5px;
display: none;
position: absolute;
}
div ul ul ul li:hover>ul{
display: block;
}
div select{
margin-left:43%;
top: 50px;
position: absolute;
display: none;
}
.rarrow{
position: absolute;
font-size: 10px;
right: -2px;
}
img{
position: relative;
left: 50%;
opacity: 0.65;
}
a{
position: relative;
left: 43%;
top: 30px;
color: white;
font-size: 22px;
font-family:oswald;
}
h5{
position: relative;
left: 43%;
color: white;
top: 35px;
}
div input{
border: none;
padding:0;
}
</style>
</head>
<body>
<form method="post">
<%
try
{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/PingData", "PingPoller", "PingPoller");
PreparedStatement ps = con.prepareStatement("SELECT * FROM LINK_MASTER");
ResultSet rs = ps.executeQuery();
%>
<p>SELECT LINK ID:</p>
<select name="S1">
<%
while(rs.next())
{
String link=rs.getString("LINK_ID");
String ip=rs.getString("IP_ADDRESS");
%>
<option value="<%=ip %>"><%=link %></option>
<%
}
}
catch(Exception e)
{
}
%>
</select><br>
<input type="Submit" name="b" value="Test">
<input type="Submit" name="b" value="Stop">
<div>
<ul>
<li>View Details<span class="rarrow">▶</span>
<ul>
<li><input type="submit" name="b1" value="Regular"></li>
<li>Monthly<span class="rarrow">▶</span>
<ul>
<li>Tabular<span class="rarrow">▶</span>
<ul>
<li><input type="submit" name="b1" value="Up details"></li>
<li><input type="submit" name="b1" value="Down details"></li>
</ul>
</li>
<li><input type="submit" name="b1" value="Graphical"></li>
<ul>
<%
try
{
Class.forName("org.apache.derby.jdbc.ClientDriver");
Connection con = DriverManager.getConnection("jdbc:derby://localhost:1527/PingData", "PingPoller", "PingPoller");
PreparedStatement ps = con.prepareStatement("SELECT * FROM DOWNTIME_SUMMARY");
ResultSet rs = ps.executeQuery();
%>
<select name="m">
<%
while(rs.next())
{
String month=rs.getString("MONTH");
%>
<option value="<%=month%>"><%=month%></option>
<%
}
}
catch(Exception e)
{
}
%>
</select>
</ul>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</form>
</body>
</html>