From d4d0538996ddee739758c9f587a32ad381b7c052 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Thu, 9 Nov 2023 22:18:37 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9B=86=E7=BE=A4=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/redis/index.html | 1 + plugins/redis/index.py | 42 ++++++++++++++++++++++++++++++++++ plugins/redis/js/redis.js | 47 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 90 insertions(+) diff --git a/plugins/redis/index.html b/plugins/redis/index.html index c2e8bfad2..a2b0ad7c2 100755 --- a/plugins/redis/index.html +++ b/plugins/redis/index.html @@ -18,6 +18,7 @@

性能调整

负载状态

复制状态

+

集群状态

日志

diff --git a/plugins/redis/index.py b/plugins/redis/index.py index 8a81ec0b0..3bc0b6f87 100755 --- a/plugins/redis/index.py +++ b/plugins/redis/index.py @@ -352,6 +352,46 @@ def infoReplication(): return mw.getJson(result) +def clusterInfo(): + #集群信息 + s = status() + if s == 'stop': + return mw.returnJson(False, '未启动') + + cmd = getRedisCmd() + cmd = cmd + 'cluster info' + + # print(cmd) + data = mw.execShell(cmd)[0] + # print(data) + + res = [ + 'cluster_state',#状态 + 'cluster_slots_assigned', # 被分配的槽 + 'cluster_slots_ok', # 被分配的槽状态 + 'cluster_slots_pfail', # 连接主库状态 + 'cluster_slots_fail', # 失败的槽 + 'cluster_known_nodes', # 知道的节点 + 'cluster_size', # 大小 + 'cluster_current_epoch', # + 'cluster_my_epoch', # + 'cluster_stats_messages_sent', # 发送 + 'cluster_stats_messages_received', # 接受 + 'total_cluster_links_buffer_limit_exceeded', # + ] + + data = data.split("\n") + result = {} + for d in data: + if len(d) < 3: + continue + t = d.strip().split(':') + if not t[0] in res: + continue + result[t[0]] = t[1] + + return mw.getJson(result) + def initdStatus(): current_os = mw.getOs() if current_os == 'darwin': @@ -496,6 +536,8 @@ if __name__ == "__main__": print(runInfo()) elif func == 'info_replication': print(infoReplication()) + elif func == 'cluster_info': + print(clusterInfo()) elif func == 'conf': print(getConf()) elif func == 'run_log': diff --git a/plugins/redis/js/redis.js b/plugins/redis/js/redis.js index 1273eed1f..459a0e4a4 100755 --- a/plugins/redis/js/redis.js +++ b/plugins/redis/js/redis.js @@ -144,6 +144,53 @@ function replStatus(version){ $(".soft-man-con").html(con); }); } + +function clusterStatus(version){ + redisPost('cluster_info', version, {},function(data){ + var rdata = $.parseJSON(data.data); + + if ('status' in rdata && !rdata.status){ + layer.msg(rdata.msg,{icon:0,time:2000,shade: [0.3, '#000']}); + return; + } + + var kv = { + 'cluster_state':'集群状态', + 'cluster_slots_assigned':'被分配的槽', + 'cluster_slots_ok':'被分配的槽状态', + 'cluster_known_nodes':'知道的节点', + 'cluster_size':'大小', + 'cluster_stats_messages_sent':'发送', + 'cluster_stats_messages_received':'接收', + 'cluster_current_epoch':'集群当前epoch', + 'cluster_my_epoch':'当前我的epoch', + 'cluster_slots_pfail':'处于PFAIL状态的节点槽数', + 'cluster_slots_fail':'处于FAIL状态的节点槽数', + 'total_cluster_links_buffer_limit_exceeded':'超出缓冲区总数', + } + + var tbody_text = ''; + for (k in rdata){ + var desc = k; + if (k in kv){ + desc = kv[k]; + } + + if (k == 'master_replid'){ + tbody_text += ''+k+'' + rdata[k] + ''+desc+''; + } else{ + tbody_text += ''+k+'' + rdata[k] + ''+desc+''; + } + } + + var con = '
\ + \ + \ + '+tbody_text+'\ +
字段当前值说明
'; + $(".soft-man-con").html(con); + }); +} //redis状态 end //配置修改