mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-20 08:25:50 +08:00
update
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
<p onclick="pluginConfig('mongodb');">配置修改</p>
|
||||
<p onclick="mongoStatus();">负载状态</p>
|
||||
<p onclick="mongoDocStatus();">文档状态</p>
|
||||
<p onclick="mongoReplStatus();">复制状态</p>
|
||||
<p onclick="pluginLogs('mongodb','','run_log');">日志</p>
|
||||
</div>
|
||||
<div class="bt-w-con pd15">
|
||||
|
||||
@@ -177,7 +177,7 @@ def runInfo():
|
||||
serverStatus = db.command('serverStatus')
|
||||
|
||||
listDbs = client.list_database_names()
|
||||
|
||||
|
||||
result = {}
|
||||
result["host"] = serverStatus['host']
|
||||
result["version"] = serverStatus['version']
|
||||
@@ -217,6 +217,31 @@ def runDocInfo():
|
||||
return mw.getJson(result)
|
||||
|
||||
|
||||
def runReplInfo():
|
||||
import pymongo
|
||||
|
||||
port = getConfPort()
|
||||
client = pymongo.MongoClient(host='127.0.0.1', port=int(port))
|
||||
db = client.admin
|
||||
serverStatus = db.command('serverStatus')
|
||||
|
||||
result = {}
|
||||
result['status'] = '无'
|
||||
result['doc_name'] = '无'
|
||||
if 'repl' in serverStatus:
|
||||
repl = serverStatus['repl']
|
||||
# print(repl)
|
||||
if repl['ismaster']:
|
||||
result['status'] = '主'
|
||||
else:
|
||||
result['status'] = '从'
|
||||
|
||||
result['setName'] = repl['setName']
|
||||
result['primary'] = repl['primary']
|
||||
result['me'] = repl['me']
|
||||
|
||||
return mw.returnJson(True, 'OK', result)
|
||||
|
||||
def initdStatus():
|
||||
if mw.isAppleSystem():
|
||||
return "Apple Computer does not support"
|
||||
@@ -301,6 +326,8 @@ if __name__ == "__main__":
|
||||
print(runInfo())
|
||||
elif func == 'run_doc_info':
|
||||
print(runDocInfo())
|
||||
elif func == 'run_repl_info':
|
||||
print(runReplInfo())
|
||||
elif func == 'conf':
|
||||
print(getConf())
|
||||
elif func == 'run_log':
|
||||
|
||||
@@ -66,4 +66,37 @@ function mongoDocStatus() {
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
},'json');
|
||||
}
|
||||
}
|
||||
|
||||
function mongoReplStatus() {
|
||||
var loadT = layer.msg('正在获取...', { icon: 16, time: 0, shade: 0.3 });
|
||||
$.post('/plugins/run', {name:'mongodb', func:'run_repl_info'}, function(data) {
|
||||
layer.close(loadT);
|
||||
if (!data.status){
|
||||
layer.msg(data.msg,{icon:0,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
var rdata = $.parseJSON(data.data);
|
||||
var rdata = rdata.data;
|
||||
|
||||
var con = '<div class="divtable">\
|
||||
<table class="table table-hover table-bordered" style="width: 490px;">\
|
||||
<thead><th>字段</th><th>当前值</th><th>说明</th></thead>\
|
||||
<tbody>\
|
||||
<tr><th>状态</th><td>' + rdata.status + '</td><td>主/从</td></tr>\
|
||||
<tr><th>同步文档</th><td>' + rdata.setName + '</td><td>文档名</td></tr>\
|
||||
<tr><th>primary</th><td>' + rdata.primary + '</td><td>primary</td></tr>\
|
||||
<tr><th>me</th><td>' + rdata.me + '</td><td>me</td></tr>\
|
||||
<tbody>\
|
||||
</table>\
|
||||
</div>';
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
},'json');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user