From 558bfcb1ee45110d90a16cf1b4dbc146f694d24d Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Wed, 20 Dec 2023 01:15:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- class/core/config_api.py | 2 +- class/core/system_api.py | 13 +++-- route/static/app/index.js | 93 ++++++++++++++++-------------- route/static/app/soft.js | 7 ++- route/templates/default/index.html | 2 +- 5 files changed, 66 insertions(+), 51 deletions(-) diff --git a/class/core/config_api.py b/class/core/config_api.py index 7c255ab78..1002d8840 100755 --- a/class/core/config_api.py +++ b/class/core/config_api.py @@ -27,7 +27,7 @@ from flask import request class config_api: - __version = '0.16.2.1' + __version = '0.16.2.2' __api_addr = 'data/api.json' def __init__(self): diff --git a/class/core/system_api.py b/class/core/system_api.py index 60a0e2aa7..939b7634b 100755 --- a/class/core/system_api.py +++ b/class/core/system_api.py @@ -299,7 +299,8 @@ class system_api: data_list = data.strip().split("\n") mac_version = '' for x in data_list: - mac_version += x.split("\t")[1] + ' ' + xlist = x.split("\t") + mac_version += xlist[len(xlist)-1] + ' ' arch_ver = mw.execShell("arch") return mac_version + " (" + arch_ver[0].strip() + ")" @@ -366,15 +367,15 @@ class system_api: mem = psutil.virtual_memory() if mw.getOs() == 'darwin': memInfo = { - 'memTotal': mem.total / 1024 / 1024 + 'memTotal': mem.total, } memInfo['memRealUsed'] = memInfo['memTotal'] * (mem.percent / 100) else: memInfo = { - 'memTotal': mem.total / 1024 / 1024, - 'memFree': mem.free / 1024 / 1024, - 'memBuffers': mem.buffers / 1024 / 1024, - 'memCached': mem.cached / 1024 / 1024 + 'memTotal': mem.total, + 'memFree': mem.free, + 'memBuffers': mem.buffers, + 'memCached': mem.cached } memInfo['memRealUsed'] = memInfo['memTotal'] - \ diff --git a/route/static/app/index.js b/route/static/app/index.js index 9538dffea..8ef4a3b8e 100755 --- a/route/static/app/index.js +++ b/route/static/app/index.js @@ -6,7 +6,7 @@ $(function() { $(this).find(".mask").css({ "color": "#d2edd8" }); $(this).find(".mem-re-con").css({ "display": "block" }); $(this).find(".mem-re-con").animate({ "top": "0", opacity: 1 }); - $("#memory").text(lan.index.memre); + $("#memory").text('内存释放'); } }, function() { $(this).removeClass("shine_green"); @@ -200,27 +200,34 @@ function clearSystem() { } function setMemImg(info){ - setCookie("memRealUsed", parseInt(info.memRealUsed)); - $("#memory").html(parseInt(info.memRealUsed) + '/' + parseInt(info.memTotal) + ' (MB)'); - setCookie("mem-before", $("#memory").text()); - if (!getCookie('memSize')) setCookie('memSize', parseInt(info.memTotal)); + + var memRealUsed = toSize(info.memRealUsed); + var memTotal = toSize(info.memTotal); + + var memRealUsedVal = memRealUsed.split(' ')[0]; + var memTotalVal = memTotal.split(' ')[0]; + var unit = memTotal.split(' ')[1]; + + var mem_txt = memRealUsedVal + '/' + memTotalVal + ' ('+ unit +')'; + setCookie("mem-before", mem_txt); + $("#memory").html(mem_txt); + var memPre = Math.floor(info.memRealUsed / (info.memTotal / 100)); $("#left").html(memPre); setcolor(memPre, "#left", 75, 90, 95); - $("#state").html(info.cpuRealUsed); - setcolor(memPre, "#state", 30, 70, 90); - setImg(); + + var memFree = info.memTotal - info.memRealUsed; + if (memFree/(1024*1024) < 64) { + $("#messageError").show(); + $("#messageError").append('

当前可用物理内存小于64M,这可能导致MySQL自动停止,站点502等错误,请尝试释放内存!

') + } } function getInfo() { $.get("/system/system_total", function(info) { - setCookie("memRealUsed", parseInt(info.memRealUsed)); - $("#memory").html(parseInt(info.memRealUsed) + '/' + parseInt(info.memTotal) + ' (MB)'); - setCookie("mem-before", $("#memory").text()); - if (!getCookie('memSize')) setCookie('memSize', parseInt(info.memTotal)); - var memPre = Math.floor(info.memRealUsed / (info.memTotal / 100)); - $("#left").html(memPre); - setcolor(memPre, "#left", 75, 90, 95); + + setMemImg(info); + $("#info").html(info.system); $("#running").html(info.time); var _system = info.system; @@ -241,13 +248,8 @@ function getInfo() { } $("#core").html(info.cpuNum + ' 核心'); $("#state").html(info.cpuRealUsed); - setcolor(memPre, "#state", 30, 70, 90); - var memFree = info.memTotal - info.memRealUsed; - - if (memFree < 64) { - $("#messageError").show(); - $("#messageError").append('

' + lan.index.mem_warning + '

') - } + setcolor(info.cpuRealUsed, "#state", 30, 70, 90); + // if (info.isuser > 0) { // $("#messageError").show(); @@ -281,6 +283,7 @@ function setcolor(pre, s, s1, s2, s3) { function getNet() { var up, down; $.get("/system/network", function(net) { + $("#InterfaceSpeed").html(lan.index.interfacespeed + ": 1.0Gbps"); $("#upSpeed").html(toSize(net.up)); $("#downSpeed").html(toSize(net.down)); @@ -293,12 +296,17 @@ function getNet() { setcolor(net.cpu[0], "#state", 30, 70, 90); setCookie("upNet", net.up); setCookie("downNet", net.down); + + //负载 getLoad(net.load); - - // setMemImg(net.mem); - setImg(); + //内存 + setMemImg(net.mem); + + //绑定hover事件 + setImg(); showCpuTips(net); + },'json'); } @@ -344,7 +352,7 @@ function netImg() { tmp = getCookie("downNet"); } var tmpSize = toSize(tmp); - default_unit = tmpSize.split(' ')[1]; + default_unit = tmpSize.split(' ')[1] + '/s'; var upNetTmp = toSize(getCookie("upNet")); @@ -399,14 +407,10 @@ function netImg() { yAxis: { name: '单位 '+ default_unit, splitLine: { - lineStyle: { - color: "#eee" - } + lineStyle: { color: "#eee" } }, axisLine: { - lineStyle: { - color: "#666" - } + lineStyle: { color: "#666" } } }, series: [{ @@ -474,6 +478,11 @@ function netImg() { getNet(); addData(true); echartsNetImg.setOption({ + yAxis: { + name: '单位 '+ default_unit, + splitLine: { lineStyle: { color: "#eee" } }, + axisLine: { lineStyle: { color: "#666" } } + }, xAxis: { data: xData }, @@ -632,7 +641,6 @@ function reBoot() { content: '
' }); - $('.rebt-con a').click(function () { var type = $(this).attr('data-id'); switch (type) { @@ -757,6 +765,7 @@ function setSafeHide() { setCookie('safeMsg', '1'); $("#safeMsg").remove(); } + //查看报告 function showDanger(num, port) { var atxt = "因未使用安全隔离登录,所有IP都可以尝试连接,存在较高风险,请立即处理。"; @@ -770,15 +779,15 @@ function showDanger(num, port) { closeBtn: 1, shift: 5, content: '
\ - \ - \ - \ - \ - \ - \ -
风险类型:暴力破解 说明
累计遭遇攻击总数:' + num + ' 详细(数据直接来源本服务器日志)
风险等级:较高风险
风险描述:' + atxt + '
可参考解决方案:

方案一:修改SSH默认端口,修改SSH验证方式为数字证书,清除近期登陆日志。

方案二:购买宝塔企业运维版,一键部署安全隔离服务,高效且方便。

\ - \ -
' + \ + \ + \ + \ + \ + \ +
风险类型:暴力破解 说明
累计遭遇攻击总数:' + num + ' 详细(数据直接来源本服务器日志)
风险等级:较高风险
风险描述:' + atxt + '
可参考解决方案:

方案一:修改SSH默认端口,修改SSH验证方式为数字证书,清除近期登陆日志。

方案二:购买宝塔企业运维版,一键部署安全隔离服务,高效且方便。

\ +
立即部署隔离防护
\ + ' }); $(".showDanger td").css("padding", "8px") } diff --git a/route/static/app/soft.js b/route/static/app/soft.js index 3dd364025..eacbfcf5f 100755 --- a/route/static/app/soft.js +++ b/route/static/app/soft.js @@ -403,7 +403,12 @@ function indexListHtml(callback){ //首页软件列表 function indexSoft() { indexListHtml(function(){ - $("#indexsoft").dragsort({ dragSelector: ".spanmove", dragBetween: true, dragEnd: saveOrder, placeHolderTemplate: "
" }); + $("#indexsoft").dragsort({ + dragSelector: ".spanmove", + dragBetween: true, + dragEnd: saveOrder, + placeHolderTemplate: "
" + }); }); function saveOrder() { diff --git a/route/templates/default/index.html b/route/templates/default/index.html index 26f627483..a2c233e85 100755 --- a/route/templates/default/index.html +++ b/route/templates/default/index.html @@ -135,7 +135,7 @@ setTimeout(function() { setTimeout(function() { getInfo(); -}, 1500); +}, 200); {% endblock %} \ No newline at end of file