From 7c147fed69ac7cd8dd8ff4c7073b9f25c16cde5b Mon Sep 17 00:00:00 2001 From: midoks Date: Mon, 1 Aug 2022 01:29:03 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E6=B8=85=E7=90=86BINLOG?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/mysql/index.py | 9 +++++++++ plugins/mysql/js/mysql.js | 30 ++++++++++++++++++++---------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index e4576f9b2..ae1ca45ed 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -248,6 +248,13 @@ def binLog(): return mw.returnJson(True, '设置成功!') +def cleanBinLog(): + db = pMysqlDb() + cleanTime = time.strftime('%Y-%m-%d %H:%i:%s', time.localtime()) + db.execute("PURGE MASTER LOGS BEFORE '" + cleanTime + "';") + return mw.returnJson(True, '清理BINLOG成功!') + + def setSkipGrantTables(v): ''' 设置是否密码验证 @@ -2068,6 +2075,8 @@ if __name__ == "__main__": print(getConf()) elif func == 'bin_log': print(binLog()) + elif func == 'clean_bin_log': + print(cleanBinLog()) elif func == 'error_log': print(getErrorLog()) elif func == 'show_log': diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index 980d0983d..57272caea 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -1031,10 +1031,18 @@ function myLogs(){ myPost('bin_log', {status:1}, function(data){ var rdata = $.parseJSON(data.data); + var line_status = "" + if (rdata.status){ + line_status = '\ + ' + } else { + line_status = '' + } + var limitCon = '

\ 二进制日志 ' + toSize(rdata.msg) + '\ - \ -

错误日志

\ + '+line_status+'\ +

错误日志

\ \

' $(".soft-man-con").html(limitCon); @@ -1044,10 +1052,15 @@ function myLogs(){ myPost('bin_log', 'close=change', function(data){ var rdata = $.parseJSON(data.data); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); - - setTimeout(function(){ - myLogs(); - }, 2000); + setTimeout(function(){myLogs();}, 2000); + }); + }); + + $(".clean-btn-bin").click(function () { + myPost('clean_bin_log', '', function(data){ + var rdata = $.parseJSON(data.data); + layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); + setTimeout(function(){myLogs();}, 2000); }); }); @@ -1056,10 +1069,7 @@ function myLogs(){ myPost('error_log', 'close=1', function(data){ var rdata = $.parseJSON(data.data); layer.msg(rdata.msg, { icon: rdata.status ? 1 : 5 }); - - setTimeout(function(){ - myLogs(); - }, 2000); + setTimeout(function(){myLogs();}, 2000); }); })