mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 02:19:25 +08:00
u
This commit is contained in:
@@ -30,6 +30,17 @@ class system_api:
|
||||
except:
|
||||
return False
|
||||
|
||||
# 检查端口是否占用
|
||||
def isOpen(self, port):
|
||||
import socket
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
try:
|
||||
s.connect(('127.0.0.1', int(port)))
|
||||
s.shutdown(2)
|
||||
return True
|
||||
except:
|
||||
return False
|
||||
|
||||
# 检测指定进程是否存活
|
||||
def checkProcess(self, pid):
|
||||
try:
|
||||
@@ -428,10 +439,9 @@ class system_api:
|
||||
start, end)).field('id,pro,one,five,fifteen,addtime').order('id asc').select()
|
||||
return self.toAddtime(data)
|
||||
|
||||
# 格式化addtime列
|
||||
def toAddtime(self, data, tomem=False):
|
||||
import time
|
||||
# 格式化addtime列
|
||||
|
||||
if tomem:
|
||||
import psutil
|
||||
mPre = (psutil.virtual_memory().total / 1024 / 1024) / 100
|
||||
@@ -466,6 +476,15 @@ class system_api:
|
||||
count = 0
|
||||
return tmp
|
||||
|
||||
def setControl(self, stype, day):
|
||||
|
||||
filename = 'data/control.conf'
|
||||
|
||||
if stype == '0':
|
||||
public.execShell("rm -f " + filename)
|
||||
|
||||
return public.returnMsg(True, "设置成功!")
|
||||
|
||||
# 重启面板
|
||||
def reWeb(self, get):
|
||||
# if not public.IsRestart(): return
|
||||
|
||||
+3
-2
@@ -40,8 +40,9 @@ def diskInfo():
|
||||
return public.getJson(diskInfo)
|
||||
|
||||
|
||||
@system.route('/get_control', methods=['POST'])
|
||||
def getControl():
|
||||
@system.route('/set_control', methods=['POST'])
|
||||
def setControl():
|
||||
stype = request.form.get('type', '')
|
||||
data = {'status': True, 'day': 30}
|
||||
return public.getJson(data)
|
||||
|
||||
|
||||
@@ -122,24 +122,25 @@ function GetToday(){
|
||||
|
||||
|
||||
//取监控状态
|
||||
function GetStatus(){
|
||||
function getStatus(){
|
||||
loadT = layer.msg(lan.public.read,{icon:16,time:0})
|
||||
$.post('/system/get_control','type=-1',function(rdata){
|
||||
$.post('/system/set_control','type=-1',function(rdata){
|
||||
console.log(rdata);
|
||||
layer.close(loadT);
|
||||
if(rdata.status){
|
||||
$("#openJK").html("<input class='btswitch btswitch-ios' id='ctswitch' type='checkbox' checked><label class='btswitch-btn' for='ctswitch' onclick='SetControl()'></label>")
|
||||
$("#openJK").html("<input class='btswitch btswitch-ios' id='ctswitch' type='checkbox' checked><label class='btswitch-btn' for='ctswitch' onclick='setControl()'></label>")
|
||||
}
|
||||
else{
|
||||
$("#openJK").html("<input class='btswitch btswitch-ios' id='ctswitch' type='checkbox'><label class='btswitch-btn' for='ctswitch' onclick='SetControl()'></label>")
|
||||
$("#openJK").html("<input class='btswitch btswitch-ios' id='ctswitch' type='checkbox'><label class='btswitch-btn' for='ctswitch' onclick='setControl()'></label>")
|
||||
}
|
||||
$("#saveDay").val(rdata.day)
|
||||
})
|
||||
},'json');
|
||||
}
|
||||
|
||||
GetStatus()
|
||||
getStatus()
|
||||
|
||||
//设置监控状态
|
||||
function SetControl(act){
|
||||
function setControl(act){
|
||||
var day = $("#saveDay").val()
|
||||
if(day < 1){
|
||||
layer.msg(lan.control.save_day_err,{icon:2});
|
||||
@@ -152,7 +153,7 @@ function SetControl(act){
|
||||
}
|
||||
|
||||
loadT = layer.msg(lan.public.the,{icon:16,time:0})
|
||||
$.post('/config?action=SetControl','type='+type+'&day='+day,function(rdata){
|
||||
$.post('/system/set_control','type='+type+'&day='+day,function(rdata){
|
||||
layer.close(loadT);
|
||||
layer.msg(rdata.msg,{icon:rdata.status?1:2});
|
||||
});
|
||||
|
||||
@@ -375,8 +375,8 @@ if __name__ == "__main__":
|
||||
# p.setDaemon(True)
|
||||
# p.start()
|
||||
|
||||
#p = threading.Thread(target=btkill)
|
||||
# p.setDaemon(True)
|
||||
# p.start()
|
||||
p = threading.Thread(target=btkill)
|
||||
p.setDaemon(True)
|
||||
p.start()
|
||||
|
||||
startTask()
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
<input class="bt-input-text" id="saveDay" value="" type="number">
|
||||
</div>
|
||||
<div class="ss-text pull-left" style="margin-left:10px">
|
||||
<button class="btn btn-default btn-sm" type="button" onclick="SetControl(true);">更改</button>
|
||||
<button class="btn btn-default btn-sm" type="button" onclick="setControl(true);">更改</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mr50 pull-left" style="padding-left:50px; border-left:#ccc 1px solid; margin-right:0">
|
||||
|
||||
Reference in New Issue
Block a user