Skip to content

Commit 0456411

Browse files
Merge branch 'master' into master
2 parents f42c4e9 + 8d96dc2 commit 0456411

File tree

2 files changed

+359
-349
lines changed

2 files changed

+359
-349
lines changed

common/static/dbdiagnostic/js/db_info.js

Lines changed: 358 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,362 @@ const pgsqlDiagnosticInfo = {
2727
{ title: '后端XMIN', field: 'backend_xmin', sortable: true },
2828
{ title: '后端类型', field: 'backend_type', sortable: true },
2929
]
30-
]
30+
],
31+
32+
}
33+
34+
const mysqlDiagnosticInfo = {
35+
fieldsProcesslist: [
36+
'mysql',
37+
["All", "Not Sleep", "Query"],
38+
[{
39+
title: '',
40+
field: 'checkbox',
41+
checkbox: true
42+
}, {
43+
title: 'THEEAD ID',
44+
field: 'id',
45+
sortable: true
46+
}, {
47+
title: 'USER',
48+
field: 'user',
49+
sortable: true
50+
}, {
51+
title: 'HOST',
52+
field: 'host',
53+
sortable: true
54+
}, {
55+
title: 'DATABASE',
56+
field: 'db',
57+
sortable: true
58+
}, {
59+
title: 'TIME(s)',
60+
field: 'time',
61+
sortable: true
62+
}, {
63+
title: 'COMMAND',
64+
field: 'command',
65+
sortable: true
66+
}, {
67+
title: 'STATE',
68+
field: 'state',
69+
sortable: true
70+
}, {
71+
title: 'INFO',
72+
field: 'info',
73+
sortable: true,
74+
formatter: function (value, row, index) {
75+
if (value.length > 20) {
76+
var sql = value.substr(0, 20) + '...';
77+
return sql;
78+
} else {
79+
return value
80+
}
81+
}
82+
}, {
83+
title: '完整INFO',
84+
field: 'info',
85+
sortable: true,
86+
visible: false // 默认不显示
87+
}],
88+
function (index, row) {
89+
var html = [];
90+
$.each(row, function (key, value) {
91+
if (key === 'info') {
92+
var sql = window.sqlFormatter.format(value);
93+
//替换所有的换行符
94+
sql = sql.replace(/\r\n/g, "<br>");
95+
sql = sql.replace(/\n/g, "<br>");
96+
//替换所有的空格
97+
sql = sql.replace(/\s/g, "&nbsp;");
98+
html.push('<span>' + sql + '</span>');
99+
}
100+
});
101+
return html.join('');
102+
}
103+
],
104+
}
105+
106+
const mongoDiagnosticInfo = {
107+
fieldsProcesslist: [
108+
'mongo',
109+
["All", "Active", "Full", "Inner"],
110+
[{
111+
title: '',
112+
field: 'checkbox',
113+
checkbox: true
114+
}, {
115+
title: 'opid',
116+
field: 'opid',
117+
sortable: true
118+
}, {
119+
title: 'client',
120+
field: 'client',
121+
sortable: true
122+
}, {
123+
title: 'client_s',
124+
field: 'client_s',
125+
sortable: true
126+
}, {
127+
title: 'type',
128+
field: 'type',
129+
sortable: true
130+
}, {
131+
title: 'active',
132+
field: 'active',
133+
sortable: true
134+
}, {
135+
title: 'desc',
136+
field: 'desc',
137+
sortable: true
138+
}, {
139+
title: 'ns',
140+
field: 'ns',
141+
sortable: true
142+
}, {
143+
title: 'effectiveUsers_user',
144+
field: 'effectiveUsers_user',
145+
sortable: true
146+
}
147+
, {
148+
title: 'secs_running',
149+
field: 'secs_running',
150+
sortable: true
151+
}
152+
, {
153+
title: 'microsecs_running',
154+
field: 'microsecs_running',
155+
sortable: true
156+
}, {
157+
title: 'waitingForLock',
158+
field: 'waitingForLock',
159+
sortable: true
160+
161+
}, {
162+
title: 'locks',
163+
field: 'locks',
164+
sortable: true,
165+
formatter: function (value, row, index) {
166+
return JSON.stringify(value);
167+
},
168+
visible: false
169+
}, {
170+
title: 'lockStats',
171+
field: 'lockStats',
172+
sortable: true,
173+
formatter: function (value, row, index) {
174+
return JSON.stringify(value);
175+
},
176+
visible: false
177+
}, {
178+
title: 'command',
179+
field: 'command',
180+
sortable: true,
181+
formatter: function (value, row, index) {
182+
if (value) {
183+
let c = JSON.stringify(value);
184+
if (c.length > 20) {
185+
return c.substr(0, 80) + '...}';
186+
} else {
187+
return c;
188+
}
189+
}
190+
}
191+
}, {
192+
title: '完整command',
193+
field: 'command',
194+
sortable: true,
195+
formatter: function (value, row, index) {
196+
return JSON.stringify(value);
197+
},
198+
visible: false // 默认不显示
199+
}, {
200+
title: 'clientMetadata',
201+
field: 'clientMetadata',
202+
sortable: true,
203+
formatter: function (value, row, index) {
204+
return JSON.stringify(value);
205+
},
206+
visible: false // 默认不显示
207+
}],
208+
function (index, row) {
209+
delete row['checkbox'];
210+
return "<pre>" + jsonHighLight(JSON.stringify(row, null, 2)) + "</pre>";
211+
}
212+
],
213+
}
214+
215+
const redisDiagnosticInfo = {
216+
fieldsProcesslist: [
217+
'redis',
218+
["All"],
219+
[{
220+
title: '', // 用于多选框
221+
field: 'checkbox',
222+
checkbox: true
223+
}, {
224+
title: 'Id',
225+
field: 'id',
226+
sortable: true
227+
}, {
228+
title: '远程地址',
229+
field: 'addr',
230+
sortable: true
231+
}, {
232+
title: '本地地址',
233+
field: 'laddr',
234+
sortable: true
235+
}, {
236+
title: '客户端名称',
237+
field: 'name',
238+
sortable: true
239+
}, {
240+
title: '用户',
241+
field: 'user',
242+
sortable: true
243+
},
244+
{
245+
title: '数据库',
246+
field: 'db',
247+
sortable: true
248+
}, {
249+
title: '连接耗时(秒)',
250+
field: 'age',
251+
sortable: true
252+
}, {
253+
title: '空闲时间(秒)',
254+
field: 'idle',
255+
sortable: true
256+
}, {
257+
title: '命令',
258+
field: 'cmd',
259+
sortable: true
260+
}, {
261+
title: '总内存',
262+
field: 'tot-mem',
263+
sortable: true
264+
}, {
265+
title: '输出内存',
266+
field: 'omem',
267+
sortable: true
268+
}, {
269+
title: '标志',
270+
field: 'flags',
271+
sortable: true
272+
}, {
273+
title: '文件描述符',
274+
field: 'fd',
275+
sortable: true
276+
}, {
277+
title: '订阅数',
278+
field: 'sub',
279+
sortable: true
280+
}, {
281+
title: '模式订阅数',
282+
field: 'psub',
283+
sortable: true
284+
}, {
285+
title: 'MULTI 队列长度',
286+
field: 'multi',
287+
sortable: true
288+
}, {
289+
title: '查询缓冲区',
290+
field: 'qbuf',
291+
sortable: true
292+
}, {
293+
title: '查询缓冲区空闲',
294+
field: 'qbuf-free',
295+
sortable: true
296+
}, {
297+
title: '参数内存',
298+
field: 'argv-mem',
299+
sortable: true
300+
}, {
301+
title: '输出缓冲区长度',
302+
field: 'obl',
303+
sortable: true
304+
}, {
305+
title: '输出链长度',
306+
field: 'oll',
307+
sortable: true
308+
}, {
309+
title: '事件文件',
310+
field: 'events',
311+
sortable: true
312+
}, {
313+
title: '重定向',
314+
field: 'redir',
315+
sortable: true
316+
}],
317+
function (index, row) {
318+
var html = [];
319+
}
320+
],
321+
}
322+
const oracleDiagnosticInfo = {
323+
fieldsProcesslist: [
324+
'oracle',
325+
["All", "Active", "Others"],
326+
[{
327+
title: '',
328+
field: 'checkbox',
329+
checkbox: true
330+
}, {
331+
title: 'SESSION ID',
332+
field: 'SID',
333+
sortable: true
334+
}, {
335+
title: 'SERIAL#',
336+
field: 'SERIAL#',
337+
sortable: true
338+
}, {
339+
title: 'STATUS',
340+
field: 'STATUS',
341+
sortable: true
342+
}, {
343+
title: 'USER',
344+
field: 'USERNAME',
345+
sortable: true
346+
}, {
347+
title: 'MACHINE',
348+
field: 'MACHINE',
349+
sortable: true
350+
}, {
351+
title: 'SQL',
352+
field: 'SQL_TEXT',
353+
sortable: true,
354+
formatter: function (value, row, index) {
355+
if (row.SQL_TEXT.length > 60) {
356+
let sql = row.SQL_TEXT.substr(0, 60) + '...';
357+
return sql;
358+
} else {
359+
return value
360+
}
361+
}
362+
}, {
363+
title: 'FULL SQL',
364+
field: 'SQL_FULLTEXT',
365+
visible: false,
366+
sortable: true
367+
}, {
368+
title: 'START TIME',
369+
field: 'SQL_EXEC_START',
370+
sortable: true
371+
}],
372+
function (index, row) {
373+
var html = [];
374+
$.each(row, function (key, value) {
375+
if (key === 'SQL_FULLTEXT') {
376+
var sql = window.sqlFormatter.format(value);
377+
//替换所有的换行符
378+
sql = sql.replace(/\r\n/g, "<br>");
379+
sql = sql.replace(/\n/g, "<br>");
380+
//替换所有的空格
381+
sql = sql.replace(/\s/g, "&nbsp;");
382+
html.push('<span>' + sql + '</span>');
383+
}
384+
});
385+
return html.join('');
386+
}
387+
],
31388
}

0 commit comments

Comments
 (0)