diff --git a/plugins/redis/index.html b/plugins/redis/index.html index cf0b57f1b..be3a7fdbd 100755 --- a/plugins/redis/index.html +++ b/plugins/redis/index.html @@ -1,550 +1,16 @@ - - -
-

密钥

-

面板设置

-

面板登录日志

-

SSH设置

-

SSH日志管理

+

服务

+

配置修改

+

负载状态

-
-

- 密钥: - -

- -
    -
  • 宝塔企业运维后台连接您的服务器需要此密钥,请妥善记录并保存
  • -
  • 一但密钥丢失,可能导致您无法登录服务器
  • -
-
- - - - +
-
- \ No newline at end of file diff --git a/plugins/redis/index.py b/plugins/redis/index.py new file mode 100755 index 000000000..0503c2f73 --- /dev/null +++ b/plugins/redis/index.py @@ -0,0 +1,45 @@ +# coding:utf-8 + +import sys +import io +import os +import time + +sys.path.append(os.getcwd() + "/class/core") +import public + + +def status(): + + cmd = os.path.dirname(os.getcwd()) + "/redis/bin/redis-cli info" + data = public.execShell(cmd)[0] + res = [ + 'tcp_port', + 'uptime_in_days', # 已运行天数 + 'connected_clients', # 连接的客户端数量 + 'used_memory', # Redis已分配的内存总量 + 'used_memory_rss', # Redis占用的系统内存总量 + 'used_memory_peak', # Redis所用内存的高峰值 + 'mem_fragmentation_ratio', # 内存碎片比率 + 'total_connections_received', # 运行以来连接过的客户端的总数量 + 'total_commands_processed', # 运行以来执行过的命令的总数量 + 'instantaneous_ops_per_sec', # 服务器每秒钟执行的命令数量 + 'keyspace_hits', # 查找数据库键成功的次数 + 'keyspace_misses', # 查找数据库键失败的次数 + 'latest_fork_usec' # 最近一次 fork() 操作耗费的毫秒数 + ] + 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 public.getJson(result) + +if __name__ == "__main__": + func = sys.argv[1] + if func == 'status': + print status() diff --git a/plugins/redis/js/redis.js b/plugins/redis/js/redis.js index e69de29bb..79d680936 100755 --- a/plugins/redis/js/redis.js +++ b/plugins/redis/js/redis.js @@ -0,0 +1,49 @@ + + + +function redisService(){ + console.log('redisService'); +} + + +function redisConfig(){ + console.log('redisConfig'); +} + + +//redis负载状态 +function redisStatus() { + var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); + $.post('/plugins/run', {name:'redis', func:'status'}, function(data) { + layer.close(loadT); + if (data.code < 0){ + return; + } + + var rdata = $.parseJSON(data.data); + + hit = (parseInt(rdata.keyspace_hits) / (parseInt(rdata.keyspace_hits) + parseInt(rdata.keyspace_misses)) * 100).toFixed(2); + var Con = '
\ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ + \ +
字段当前值说明
uptime_in_days' + rdata.uptime_in_days + '已运行天数
tcp_port' + rdata.tcp_port + '当前监听端口
connected_clients' + rdata.connected_clients + '连接的客户端数量
used_memory_rss' + ToSize(rdata.used_memory_rss) + 'Redis当前占用的系统内存总量
used_memory' + ToSize(rdata.used_memory) + 'Redis当前已分配的内存总量
used_memory_peak' + ToSize(rdata.used_memory_peak) + 'Redis历史分配内存的峰值
mem_fragmentation_ratio' + rdata.mem_fragmentation_ratio + '%内存碎片比率
total_connections_received' + rdata.total_connections_received + '运行以来连接过的客户端的总数量
total_commands_processed' + rdata.total_commands_processed + '运行以来执行过的命令的总数量
instantaneous_ops_per_sec' + rdata.instantaneous_ops_per_sec + '服务器每秒钟执行的命令数量
keyspace_hits' + rdata.keyspace_hits + '查找数据库键成功的次数
keyspace_misses' + rdata.keyspace_misses + '查找数据库键失败的次数
hit' + hit + '%查找数据库键命中率
latest_fork_usec' + rdata.latest_fork_usec + '最近一次 fork() 操作耗费的微秒数
' + $(".soft-man-con").html(Con); + },'json'); +} +redisStatus(); diff --git a/route/plugins.py b/route/plugins.py index 7abce1db1..88b9225ae 100644 --- a/route/plugins.py +++ b/route/plugins.py @@ -118,15 +118,27 @@ def checkInstalled(): return "False" -@plugins.route('/setting', methods=["GET"]) +@plugins.route('/setting', methods=['GET']) def setting(): name = request.args.get('name', '') html = __plugin_name + '/' + name + '/index.html' return public.readFile(html) -@plugins.route('/run', methods=['POST']) +@plugins.route('/run', methods=['POST', 'GET']) def run(): - name = request.args.get('name', '') - html = __plugin_name + '/' + name + '/main.html' - return "False" + + name = request.form.get('name', '') + func = request.form.get('func', '') + args = request.form.get('args', '') + + py = 'python ' + public.getRunDir() + '/' + __plugin_name + '/' + name + if args == '': + py = py + '/index.py' + ' ' + func + else: + py = py + '/index.py' + ' ' + func + ' ' + args + + data = public.execShell(py) + if data[1].strip() == '': + return public.getJson({"data": data[0].strip(), "code": 0}) + return public.getJson({"data": data[1].strip(), "code": -1}) diff --git a/static/js/public.js b/static/js/public.js index e45c4aefd..c38ff4399 100755 --- a/static/js/public.js +++ b/static/js/public.js @@ -1552,11 +1552,7 @@ function check_login(){ }); } -$(function(){ - setInterval(function(){ - check_login(); - },60000); -}); + //登陆跳转 function to_login(){ @@ -1572,4 +1568,11 @@ function table_fixed(name){ function scroll_handle(e){ var scrollTop = this.scrollTop; $(this).find("thead").css({"transform":"translateY("+scrollTop+"px)","position":"relative","z-index":"1"}); -} \ No newline at end of file +} + + +$(function(){ + setInterval(function(){ + check_login(); + },60000); +}); \ No newline at end of file diff --git a/static/js/soft.js b/static/js/soft.js index 284d84f64..a7513daab 100755 --- a/static/js/soft.js +++ b/static/js/soft.js @@ -913,12 +913,9 @@ function GetPHPStatus(version) { //软件管理窗口 function SoftMan(name, version) { - var loadT = layer.msg("正在处理,请稍后...", { icon: 16, time: 0, shade: [0.3, '#000'] }); $.get('/plugins/setting?name='+name, function(rdata) { - // console.log(rdata) layer.close(loadT); - layer.open({ type: 1, area: '640px', @@ -927,43 +924,12 @@ function SoftMan(name, version) { shift: 0, content: rdata }); - // service(name, nameA.status); $(".bt-w-menu p").click(function() { - //var i = $(this).index(); $(this).addClass("bgw").siblings().removeClass("bgw"); }); }); } -//redis负载状态 -function RedisStatus() { - var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 }); - $.get('/ajax?action=GetRedisStatus', function(rdata) { - layer.close(loadT); - hit = (parseInt(rdata.keyspace_hits) / (parseInt(rdata.keyspace_hits) + parseInt(rdata.keyspace_misses)) * 100).toFixed(2); - var Con = '
\ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ - \ -
字段当前值说明
uptime_in_days' + rdata.uptime_in_days + '已运行天数
tcp_port' + rdata.tcp_port + '当前监听端口
connected_clients' + rdata.connected_clients + '连接的客户端数量
used_memory_rss' + ToSize(rdata.used_memory_rss) + 'Redis当前占用的系统内存总量
used_memory' + ToSize(rdata.used_memory) + 'Redis当前已分配的内存总量
used_memory_peak' + ToSize(rdata.used_memory_peak) + 'Redis历史分配内存的峰值
mem_fragmentation_ratio' + rdata.mem_fragmentation_ratio + '%内存碎片比率
total_connections_received' + rdata.total_connections_received + '运行以来连接过的客户端的总数量
total_commands_processed' + rdata.total_commands_processed + '运行以来执行过的命令的总数量
instantaneous_ops_per_sec' + rdata.instantaneous_ops_per_sec + '服务器每秒钟执行的命令数量
keyspace_hits' + rdata.keyspace_hits + '查找数据库键成功的次数
keyspace_misses' + rdata.keyspace_misses + '查找数据库键失败的次数
hit' + hit + '%查找数据库键命中率
latest_fork_usec' + rdata.latest_fork_usec + '最近一次 fork() 操作耗费的微秒数
' - $(".soft-man-con").html(Con); - }); -} //memcached负载状态 function MemcachedStatus() { @@ -2312,8 +2278,8 @@ function flush_cache() { } -$(function() { - if (window.document.location.pathname == '/soft/') { - setInterval(function() { GetSList(true); }, 5000); - } -}); \ No newline at end of file +// $(function() { +// if (window.document.location.pathname == '/soft/') { +// setInterval(function() { GetSList(true); }, 5000); +// } +// }); \ No newline at end of file