profiler.jsp
7.85 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
<%@ page language="java" contentType="text/html; charset=GBK" %>
<%@ include file="/systeminfo/init_wev8.jsp" %>
<%@ taglib uri="/WEB-INF/weaver.tld" prefix="wea"%>
<%@ page import="java.lang.management.ManagementFactory" %>
<%@ page import="java.lang.management.ThreadInfo" %>
<%@ page import="java.lang.management.ThreadMXBean" %>
<%@ page import="weaver.general.TimeUtil" %>
<%@ page import="java.util.Properties" %>
<%@ page import="java.util.UUID" %>
<%@ page import="weaver.general.BaseBean" %>
<%
Cookie[] cookies = request.getCookies();
if(cookies == null) {
Cookie cookie = new Cookie("profilerCookie", UUID.randomUUID().toString());
cookie.setMaxAge(60*60*24*36500);
response.addCookie(cookie);
}else{
boolean already = false;
for(int i=0; i<cookies.length; i++) {
// 获得具体的Cookie
Cookie cookie = cookies[i];
// 获得Cookie的名称
String name = cookie.getName();
if(name.equals("profilerCookie")){
already = true;
break;
}
}
if(!already){
Cookie cookie = new Cookie("profilerCookie", UUID.randomUUID().toString());
cookie.setMaxAge(60*60*24*36500);
response.addCookie(cookie);
}
}
%>
<html>
<head>
<script src="../profiler/js/jquery-1.4.2.min_wev8.js"></script>
<script type="text/javascript">
var jstack = false;
var unPause = true;
var first = 1;
var jstackCount = 0;
window.setInterval("jstackInvoke()",1000);
function startJstack()
{
jstack = true;
first = 1;
var startBt = document.getElementById("start");
startBt.disabled=true;
var end = document.getElementById("end");
var pause = document.getElementById("pause");
//pause.disabled=false;
end.disabled=false;
$("#start").css("background-color","#d7dcde");
$("#end").css("background-color","#2DB7F5");
}
function jstackInvoke(){
if(unPause&&jstack&&jstackCount<300){
$.post("/profiler/jstack.jsp?first="+first,function(){
if(unPause&&jstack&&jstackCount<300){
first = 0;
jstackCount++;
if(jstackCount!=300)
document.getElementById("showRunning").innerHTML = "正在输出第"+jstackCount+"个日志。。";
else
document.getElementById("showRunning").innerHTML = "日志停止输出。。";
}
});
}else if(!jstack){
document.getElementById("showRunning").innerHTML = "";
}
}
function stopJstack(){
jstack = false;
jstackCount = 0;
var startBt = document.getElementById("start");
startBt.disabled=false;
var end = document.getElementById("end");
end.disabled=true;
var pause = document.getElementById("pause");
//pause.disabled=true;
$("#end").css("background-color","#d7dcde");
$("#start").css("background-color","#2DB7F5");
}
function pauseJstack(){
if(unPause){
unPause = false;
document.getElementById("pause").innerHTML = "unPause";
var end = document.getElementById("end");
end.disabled=true;
document.getElementById("showRunning").innerHTML = "暂停输出";
}else{
document.getElementById("showRunning").innerHTML = "";
unPause = true;
document.getElementById("pause").innerHTML = "pause";
var end = document.getElementById("end");
end.disabled=false;
}
}
function getResult(){
var key = document.getElementById("keyword").value;
if(key==""){
alert("请输入卡顿请求url关键字,越详细越好!");
}else{
document.iframeAlert.document.location="getResult.jsp?key="+key;
}
}
function getOptimizationResult(){
var key = document.getElementById("keyword").value;
if(key==""){
alert("请输入卡顿请求url关键字,越详细越好!");
}else{
document.iframeAlert.document.location="getOptimizationResult.jsp?key="+key;
}
}
function toggle(){
jQuery("#hiddenAreaDiv").toggle();
if(jQuery("#hiddenAreaDiv").css("display")=="none"){
jQuery("#toolbar").css("background-image","url(img/down.png)");
}else{
jQuery("#toolbar").css("background-image","url(img/up.png)");
}
resizeDivSize();
}
function keyDown(e) {
var ev= window.event||e;
if (ev.keyCode == 13) {
getResult();
}
}
function resizeDivSize(){
jQuery("#bottomHalfArea").height(jQuery(window).height()-jQuery("#topHalfArea").height()-10);
}
jQuery(window).resize(function() {
resizeDivSize();
});
jQuery(document).ready(function(){
resizeDivSize();
});
</script>
</head>
<body style="width:95%;margin:0 auto;">
<div id="topHalfArea">
<div style="width:100%;background-color:#E7FBFF;border-radius:4px;">
<div id="toolbar" style="cursor:pointer;font-family: 微软雅黑;font-size: 16px;color: #333333;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:10px;padding-top:10px;font-weight:bold; background-image:url(img/up.png);background-repeat:no-repeat;background-position:center right;margin-right:10px;" onclick="toggle()">操作步骤:</div>
<div id="hiddenAreaDiv">
<div style="font-family: 微软雅黑;font-size: 14px;color: #333333;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:10px">1、点击'start'开始采集信息</div>
<div style="font-family: 微软雅黑;font-size: 14px;color: #333333;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:10px">2、切换到慢的页面,进行操作,等页面返回以后(如果一直不返还,比如死循环,那么等10秒即可)</div>
<div style="font-family: 微软雅黑;font-size: 14px;color: #333333;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:10px">3、点击'stop'结束采集信息</div>
<div style="font-family: 微软雅黑;font-size: 14px;color: #333333;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:10px">4、在下面的输入框里输入要分析的URL后,点击'分析'获取瓶颈点</div>
<p>
<div style='color:red'>
<div style="font-family: 微软雅黑;font-size: 16px;color: #FF0917;letter-spacing: -0.02px;line-height: 16px;margin-left:40px;padding-bottom:10px;font-weight:bold;">注意:</div>
<div style="font-family: 微软雅黑;font-size: 14px;color: #FF0917;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:10px">URL需要做些替换:</div>
<div style="font-family: 微软雅黑;font-size: 14px;color: #FF0917;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:10px">/ 替换为 ._</div>
<div style="font-family: 微软雅黑;font-size: 14px;color: #FF0917;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:10px">. 替换为 __(两个下划线)</div>
<div style="font-family: 微软雅黑;font-size: 14px;color: #FF0917;letter-spacing: -0.02px;line-height: 14px;margin-left:40px;padding-bottom:30px">比如 /login/login.jsp 可以输入 ._login._login__jsp,也可以直接输入 login 模糊匹配即可,结果如果不够准确,可以从结果中拷贝URL到输入框再分析一次</div>
</div>
</div>
</div>
<div style="height:60px;line-height:60px;">
<button type="button" onclick="startJstack()" id="start" style="border:none;background: #2DB7F5;border-radius: 4px;width:68px;height:30px;font-family: 微软雅黑;font-size: 14px;color: #FFFFFF;letter-spacing: -0.01px;line-height: 12px;">start</button>
<button type="button" onclick="stopJstack()" disabled="true" id="end" style="border:none;background: #d7dcde;border-radius: 4px;width:68px;height:30px;font-family: 微软雅黑;font-size: 14px;color: #FFFFFF;letter-spacing: -0.01px;line-height: 12px;">stop</button>
<span id="showRunning" style="font-family: 微软雅黑;font-size: 14px;color: #333333;letter-spacing: -0.02px;line-height: 14px;height:60px;line-height:60px;"></span>
</div>
<div style="height:60px;line-height:60px;">
<span style="font-family: 微软雅黑;font-size: 16px;color: #FF0917;letter-spacing: -0.02px;line-height: 16px;font-weight:bold;">关键字:</span><span><input type="text" id="keyword" name="keyword" onkeydown="keyDown(event)" style="width:600px;height:34px;background: #FFFFFF;border: 1px solid #979797;" /></span>
<button type="button" onclick="getResult()" style="background: #2DB7F5;border-radius: 4px;width:67px;height:30px;color:white;border:none;">分 析</button>
</div>
</div>
<div id="bottomHalfArea" style="background: #FFFFFF;border: 1px solid #979797;border-radius: 4px;">
<iframe
src="getResult.jsp"
id="iframeAlert" name="iframeAlert" frameborder="0"
style="width: 100%; height: 100%; "
scrolling="auto"></iframe>
</div>
</body>
</html>