diff --git a/plugins/mysql/index.py b/plugins/mysql/index.py index 459a830d0..2314bfd24 100755 --- a/plugins/mysql/index.py +++ b/plugins/mysql/index.py @@ -358,7 +358,7 @@ def binLogList(): for x in range(len(alist)): f = alist[x] t = {} - if f.startswith(log_bin_name) and f != (log_bin_name + '.index'): + if f.startswith(log_bin_name) and not f.endswith('.index'): abspath = data_dir + '/' + f t['name'] = f t['size'] = os.path.getsize(abspath) @@ -387,22 +387,6 @@ def binLogList(): return mw.getJson(data) -def binLogListLook(): - args = getArgs() - data = checkArgs(args, ['file']) - if not data[0]: - return data[1] - - data_dir = getDataDir() - my_bin = getServerDir() + '/bin' - my_binlog_cmd = my_bin + '/mysqlbinlog' - - cmd = my_binlog_cmd + ' --no-defaults --base64-output=decode-rows -vvvv ' + \ - data_dir + '/' + args['file'] + '|tail -50' - - print(cmd) - - def cleanBinLog(): db = pMysqlDb() cleanTime = time.strftime('%Y-%m-%d %H:%i:%s', time.localtime()) diff --git a/plugins/mysql/index_mysql.py b/plugins/mysql/index_mysql.py index 9a03ca285..5b3254622 100644 --- a/plugins/mysql/index_mysql.py +++ b/plugins/mysql/index_mysql.py @@ -53,6 +53,22 @@ def getDataDir(): return tmp.groups()[0].strip() +def getRelayLogName(): + file = getConf() + content = mw.readFile(file) + rep = 'relay-log\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + +def getLogBinName(): + file = getConf() + content = mw.readFile(file) + rep = 'log-bin\s*=\s*(.*)' + tmp = re.search(rep, content) + return tmp.groups()[0].strip() + + def binLogListLook(args): file = args['file'] @@ -93,3 +109,72 @@ def binLogListLookDecode(args): rdata['data'] = data[0] return rdata + + +def binLogListTraceRelay(args): + + file = args['file'] + line = args['line'] + + relay_name = getRelayLogName() + data_dir = getDataDir() + alist = os.listdir(data_dir) + relay_list = [] + for x in range(len(alist)): + f = alist[x] + t = {} + if f.startswith(relay_name) and not f.endswith('.index'): + relay_list.append(f) + + file = relay_list[0] + + my_bin = getServerDir() + '/bin' + my_binlog_cmd = my_bin + '/mysqlbinlog' + + cmd = my_binlog_cmd + ' --no-defaults --base64-output=decode-rows -vvvv ' + \ + data_dir + '/' + file + '|tail -' + str(line) + + data = mw.execShell(cmd) + + rdata = {} + rdata['cmd'] = cmd + rdata['data'] = data[0] + + return rdata + + +def binLogListTraceBinLog(args): + rdata = {} + file = args['file'] + line = args['line'] + + data_dir = getDataDir() + log_bin_name = getLogBinName() + + alist = os.listdir(data_dir) + log_bin_l = [] + for x in range(len(alist)): + f = alist[x] + t = {} + if f.startswith(log_bin_name) and not f.endswith('.index'): + log_bin_l.append(f) + + if len(log_bin_l) == 0: + rdata['cmd'] = '' + rdata['data'] = '无BINLOG' + return rdata + + file = log_bin_l[0] + + my_bin = getServerDir() + '/bin' + my_binlog_cmd = my_bin + '/mysqlbinlog' + + cmd = my_binlog_cmd + ' --no-defaults --base64-output=decode-rows -vvvv ' + \ + data_dir + '/' + file + '|tail -' + str(line) + + data = mw.execShell(cmd) + + rdata['cmd'] = cmd + rdata['data'] = data[0] + + return rdata diff --git a/plugins/mysql/js/mysql.js b/plugins/mysql/js/mysql.js index d94181e4a..45e2656da 100755 --- a/plugins/mysql/js/mysql.js +++ b/plugins/mysql/js/mysql.js @@ -1243,7 +1243,7 @@ function myBinRollingLogs(_name, func, _args, line){ copyText(cmd); }); - var ebody = ''; + var ebody = ''; $("#my_rolling_logs").html(ebody); var ob = document.getElementById('roll_info_log'); ob.scrollTop = ob.scrollHeight; @@ -1254,7 +1254,7 @@ function myBinRollingLogs(_name, func, _args, line){ layer.open({ type: 1, title: _name + '日志', - area: '640px', + area: ['800px','700px'], end: function(){ if (reqTimer){ clearInterval(reqTimer); @@ -1270,14 +1270,14 @@ function myBinRollingLogs(_name, func, _args, line){ \ \