From 6e2b26272682f3142d60cd73c36d816956627239 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=A3=9E?= Date: Fri, 20 Dec 2024 17:06:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=9A=E8=AF=9D=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD-=E8=BF=9B=E7=A8=8B=E6=8B=86=E5=87=BAJS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- common/static/dbdiagnostic/js/db_info.js | 359 ++++++++++++++++++++++- sql/templates/dbdiagnostic.html | 349 +--------------------- 2 files changed, 359 insertions(+), 349 deletions(-) diff --git a/common/static/dbdiagnostic/js/db_info.js b/common/static/dbdiagnostic/js/db_info.js index 416fe4cecd..3a1282ad39 100644 --- a/common/static/dbdiagnostic/js/db_info.js +++ b/common/static/dbdiagnostic/js/db_info.js @@ -27,5 +27,362 @@ const pgsqlDiagnosticInfo = { { title: '后端XMIN', field: 'backend_xmin', sortable: true }, { title: '后端类型', field: 'backend_type', sortable: true }, ] - ] + ], + +} + +const mysqlDiagnosticInfo = { + fieldsProcesslist: [ + 'mysql', + ["All", "Not Sleep", "Query"], + [{ + title: '', + field: 'checkbox', + checkbox: true + }, { + title: 'THEEAD ID', + field: 'id', + sortable: true + }, { + title: 'USER', + field: 'user', + sortable: true + }, { + title: 'HOST', + field: 'host', + sortable: true + }, { + title: 'DATABASE', + field: 'db', + sortable: true + }, { + title: 'TIME(s)', + field: 'time', + sortable: true + }, { + title: 'COMMAND', + field: 'command', + sortable: true + }, { + title: 'STATE', + field: 'state', + sortable: true + }, { + title: 'INFO', + field: 'info', + sortable: true, + formatter: function (value, row, index) { + if (value.length > 20) { + var sql = value.substr(0, 20) + '...'; + return sql; + } else { + return value + } + } + }, { + title: '完整INFO', + field: 'info', + sortable: true, + visible: false // 默认不显示 + }], + function (index, row) { + var html = []; + $.each(row, function (key, value) { + if (key === 'info') { + var sql = window.sqlFormatter.format(value); + //替换所有的换行符 + sql = sql.replace(/\r\n/g, "
"); + sql = sql.replace(/\n/g, "
"); + //替换所有的空格 + sql = sql.replace(/\s/g, " "); + html.push('' + sql + ''); + } + }); + return html.join(''); + } + ], +} + +const mongoDiagnosticInfo = { + fieldsProcesslist: [ + 'mongo', + ["All", "Active", "Full", "Inner"], + [{ + title: '', + field: 'checkbox', + checkbox: true + }, { + title: 'opid', + field: 'opid', + sortable: true + }, { + title: 'client', + field: 'client', + sortable: true + }, { + title: 'client_s', + field: 'client_s', + sortable: true + }, { + title: 'type', + field: 'type', + sortable: true + }, { + title: 'active', + field: 'active', + sortable: true + }, { + title: 'desc', + field: 'desc', + sortable: true + }, { + title: 'ns', + field: 'ns', + sortable: true + }, { + title: 'effectiveUsers_user', + field: 'effectiveUsers_user', + sortable: true + } + , { + title: 'secs_running', + field: 'secs_running', + sortable: true + } + , { + title: 'microsecs_running', + field: 'microsecs_running', + sortable: true + }, { + title: 'waitingForLock', + field: 'waitingForLock', + sortable: true + + }, { + title: 'locks', + field: 'locks', + sortable: true, + formatter: function (value, row, index) { + return JSON.stringify(value); + }, + visible: false + }, { + title: 'lockStats', + field: 'lockStats', + sortable: true, + formatter: function (value, row, index) { + return JSON.stringify(value); + }, + visible: false + }, { + title: 'command', + field: 'command', + sortable: true, + formatter: function (value, row, index) { + if (value) { + let c = JSON.stringify(value); + if (c.length > 20) { + return c.substr(0, 80) + '...}'; + } else { + return c; + } + } + } + }, { + title: '完整command', + field: 'command', + sortable: true, + formatter: function (value, row, index) { + return JSON.stringify(value); + }, + visible: false // 默认不显示 + }, { + title: 'clientMetadata', + field: 'clientMetadata', + sortable: true, + formatter: function (value, row, index) { + return JSON.stringify(value); + }, + visible: false // 默认不显示 + }], + function (index, row) { + delete row['checkbox']; + return "
" + jsonHighLight(JSON.stringify(row, null, 2)) + "
"; + } + ], +} + +const redisDiagnosticInfo = { + fieldsProcesslist: [ + 'redis', + ["All"], + [{ + title: '', // 用于多选框 + field: 'checkbox', + checkbox: true + }, { + title: 'Id', + field: 'id', + sortable: true + }, { + title: '远程地址', + field: 'addr', + sortable: true + }, { + title: '本地地址', + field: 'laddr', + sortable: true + }, { + title: '客户端名称', + field: 'name', + sortable: true + }, { + title: '用户', + field: 'user', + sortable: true + }, + { + title: '数据库', + field: 'db', + sortable: true + }, { + title: '连接耗时(秒)', + field: 'age', + sortable: true + }, { + title: '空闲时间(秒)', + field: 'idle', + sortable: true + }, { + title: '命令', + field: 'cmd', + sortable: true + }, { + title: '总内存', + field: 'tot-mem', + sortable: true + }, { + title: '输出内存', + field: 'omem', + sortable: true + }, { + title: '标志', + field: 'flags', + sortable: true + }, { + title: '文件描述符', + field: 'fd', + sortable: true + }, { + title: '订阅数', + field: 'sub', + sortable: true + }, { + title: '模式订阅数', + field: 'psub', + sortable: true + }, { + title: 'MULTI 队列长度', + field: 'multi', + sortable: true + }, { + title: '查询缓冲区', + field: 'qbuf', + sortable: true + }, { + title: '查询缓冲区空闲', + field: 'qbuf-free', + sortable: true + }, { + title: '参数内存', + field: 'argv-mem', + sortable: true + }, { + title: '输出缓冲区长度', + field: 'obl', + sortable: true + }, { + title: '输出链长度', + field: 'oll', + sortable: true + }, { + title: '事件文件', + field: 'events', + sortable: true + }, { + title: '重定向', + field: 'redir', + sortable: true + }], + function (index, row) { + var html = []; + } + ], +} +const oracleDiagnosticInfo = { + fieldsProcesslist: [ + 'oracle', + ["All", "Active", "Others"], + [{ + title: '', + field: 'checkbox', + checkbox: true + }, { + title: 'SESSION ID', + field: 'SID', + sortable: true + }, { + title: 'SERIAL#', + field: 'SERIAL#', + sortable: true + }, { + title: 'STATUS', + field: 'STATUS', + sortable: true + }, { + title: 'USER', + field: 'USERNAME', + sortable: true + }, { + title: 'MACHINE', + field: 'MACHINE', + sortable: true + }, { + title: 'SQL', + field: 'SQL_TEXT', + sortable: true, + formatter: function (value, row, index) { + if (row.SQL_TEXT.length > 60) { + let sql = row.SQL_TEXT.substr(0, 60) + '...'; + return sql; + } else { + return value + } + } + }, { + title: 'FULL SQL', + field: 'SQL_FULLTEXT', + visible: false, + sortable: true + }, { + title: 'START TIME', + field: 'SQL_EXEC_START', + sortable: true + }], + function (index, row) { + var html = []; + $.each(row, function (key, value) { + if (key === 'SQL_FULLTEXT') { + var sql = window.sqlFormatter.format(value); + //替换所有的换行符 + sql = sql.replace(/\r\n/g, "
"); + sql = sql.replace(/\n/g, "
"); + //替换所有的空格 + sql = sql.replace(/\s/g, " "); + html.push('' + sql + ''); + } + }); + return html.join(''); + } + ], } diff --git a/sql/templates/dbdiagnostic.html b/sql/templates/dbdiagnostic.html index 152b4d7f6d..b656257c01 100644 --- a/sql/templates/dbdiagnostic.html +++ b/sql/templates/dbdiagnostic.html @@ -106,354 +106,7 @@ // get_process_list函数表格的格式化信息 // 0.数据库类型; 1.类型过滤; 2.字段映射; 3.详细信息的处理函数 - var processListTableInfos = [ - [ - 'mysql', - ["All","Not Sleep","Query"], - [{ - title: '', - field: 'checkbox', - checkbox: true - }, { - title: 'THEEAD ID', - field: 'id', - sortable: true - }, { - title: 'USER', - field: 'user', - sortable: true - }, { - title: 'HOST', - field: 'host', - sortable: true - }, { - title: 'DATABASE', - field: 'db', - sortable: true - }, { - title: 'TIME(s)', - field: 'time', - sortable: true - }, { - title: 'COMMAND', - field: 'command', - sortable: true - }, { - title: 'STATE', - field: 'state', - sortable: true - }, { - title: 'INFO', - field: 'info', - sortable: true, - formatter: function (value, row, index) { - if (value.length > 20) { - var sql = value.substr(0, 20) + '...'; - return sql; - } else { - return value - } - } - }, { - title: '完整INFO', - field: 'info', - sortable: true, - visible: false // 默认不显示 - }], - function (index, row) { - var html = []; - $.each(row, function (key, value) { - if (key === 'info') { - var sql = window.sqlFormatter.format(value); - //替换所有的换行符 - sql = sql.replace(/\r\n/g, "
"); - sql = sql.replace(/\n/g, "
"); - //替换所有的空格 - sql = sql.replace(/\s/g, " "); - html.push('' + sql + ''); - } - }); - return html.join(''); - } - ], - [ - 'mongo', - ["All","Active","Full","Inner"], - [{ - title: '', - field: 'checkbox', - checkbox: true - }, { - title: 'opid', - field: 'opid', - sortable: true - }, { - title: 'client', - field: 'client', - sortable: true - }, { - title: 'client_s', - field: 'client_s', - sortable: true - }, { - title: 'type', - field: 'type', - sortable: true - }, { - title: 'active', - field: 'active', - sortable: true - }, { - title: 'desc', - field: 'desc', - sortable: true - }, { - title: 'ns', - field: 'ns', - sortable: true - }, { - title: 'effectiveUsers_user', - field: 'effectiveUsers_user', - sortable: true - } - , { - title: 'secs_running', - field: 'secs_running', - sortable: true - } - , { - title: 'microsecs_running', - field: 'microsecs_running', - sortable: true - }, { - title: 'waitingForLock', - field: 'waitingForLock', - sortable: true - - },{ - title: 'locks', - field: 'locks', - sortable: true, - formatter: function (value, row, index) { - return JSON.stringify(value); - }, - visible: false - }, { - title: 'lockStats', - field: 'lockStats', - sortable: true, - formatter: function (value, row, index) { - return JSON.stringify(value); - }, - visible: false - }, { - title: 'command', - field: 'command', - sortable: true, - formatter: function (value, row, index) { - if (value) { - let c = JSON.stringify(value); - if (c.length > 20) { - return c.substr(0, 80) + '...}'; - } else { - return c; - } - } - } - }, { - title: '完整command', - field: 'command', - sortable: true, - formatter: function (value, row, index) { - return JSON.stringify(value); - }, - visible: false // 默认不显示 - }, { - title: 'clientMetadata', - field: 'clientMetadata', - sortable: true, - formatter: function (value, row, index) { - return JSON.stringify(value); - }, - visible: false // 默认不显示 - }], - function (index, row) { - delete row['checkbox']; - return "
"+jsonHighLight(JSON.stringify(row, null, 2))+"
"; - } - ], - [ - 'oracle', - ["All","Active","Others"], - [{ - title: '', - field: 'checkbox', - checkbox: true - }, { - title: 'SESSION ID', - field: 'SID', - sortable: true - }, { - title: 'SERIAL#', - field: 'SERIAL#', - sortable: true - }, { - title: 'STATUS', - field: 'STATUS', - sortable: true - }, { - title: 'USER', - field: 'USERNAME', - sortable: true - }, { - title: 'MACHINE', - field: 'MACHINE', - sortable: true - }, { - title: 'SQL', - field: 'SQL_TEXT', - sortable: true, - formatter: function (value, row, index) { - if (row.SQL_TEXT.length > 60) { - let sql = row.SQL_TEXT.substr(0, 60) + '...'; - return sql; - } else { - return value - } - } - }, { - title: 'FULL SQL', - field: 'SQL_FULLTEXT', - visible: false, - sortable: true - }, { - title: 'START TIME', - field: 'SQL_EXEC_START', - sortable: true - }], - function (index, row) { - var html = []; - $.each(row, function (key, value) { - if (key === 'SQL_FULLTEXT') { - var sql = window.sqlFormatter.format(value); - //替换所有的换行符 - sql = sql.replace(/\r\n/g, "
"); - sql = sql.replace(/\n/g, "
"); - //替换所有的空格 - sql = sql.replace(/\s/g, " "); - html.push('' + sql + ''); - } - }); - return html.join(''); - } - ] - ,[ - 'redis', - ["All"], - [{ - title: '', // 用于多选框 - field: 'checkbox', - checkbox: true - }, { - title: 'Id', - field: 'id', - sortable: true - }, { - title: '远程地址', - field: 'addr', - sortable: true - }, { - title: '本地地址', - field: 'laddr', - sortable: true - }, { - title: '客户端名称', - field: 'name', - sortable: true - }, { - title: '用户', - field: 'user', - sortable: true - }, - { - title: '数据库', - field: 'db', - sortable: true - }, { - title: '连接耗时(秒)', - field: 'age', - sortable: true - }, { - title: '空闲时间(秒)', - field: 'idle', - sortable: true - }, { - title: '命令', - field: 'cmd', - sortable: true - }, { - title: '总内存', - field: 'tot-mem', - sortable: true - },{ - title: '输出内存', - field: 'omem', - sortable: true - }, { - title: '标志', - field: 'flags', - sortable: true - },{ - title: '文件描述符', - field: 'fd', - sortable: true - },{ - title: '订阅数', - field: 'sub', - sortable: true - }, { - title: '模式订阅数', - field: 'psub', - sortable: true - }, { - title: 'MULTI 队列长度', - field: 'multi', - sortable: true - }, { - title: '查询缓冲区', - field: 'qbuf', - sortable: true - }, { - title: '查询缓冲区空闲', - field: 'qbuf-free', - sortable: true - }, { - title: '参数内存', - field: 'argv-mem', - sortable: true - }, { - title: '输出缓冲区长度', - field: 'obl', - sortable: true - }, { - title: '输出链长度', - field: 'oll', - sortable: true - }, { - title: '事件文件', - field: 'events', - sortable: true - }, { - title: '重定向', - field: 'redir', - sortable: true - }], - function (index, row) { - var html = []; - } - ] - ] - + var processListTableInfos = [] if (typeof pgsqlDiagnosticInfo !== "undefined" && Array.isArray(pgsqlDiagnosticInfo.fieldsProcesslist)) { processListTableInfos.push(pgsqlDiagnosticInfo?.fieldsProcesslist);