diff --git a/plugins/mongodb/index.html b/plugins/mongodb/index.html
index 2eebee2eb..8eb11a49a 100755
--- a/plugins/mongodb/index.html
+++ b/plugins/mongodb/index.html
@@ -6,6 +6,7 @@
diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py
index 7d7fc3282..00ad07d7d 100755
--- a/plugins/mongodb/index.py
+++ b/plugins/mongodb/index.py
@@ -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':
diff --git a/plugins/mongodb/js/mongodb.js b/plugins/mongodb/js/mongodb.js
index abb56bf95..bf0b715d9 100644
--- a/plugins/mongodb/js/mongodb.js
+++ b/plugins/mongodb/js/mongodb.js
@@ -66,4 +66,37 @@ function mongoDocStatus() {
$(".soft-man-con").html(con);
},'json');
-}
\ No newline at end of file
+}
+
+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 = '
\
+
\
+ 字段 | 当前值 | 说明 | \
+ \
+ 状态 | ' + rdata.status + ' | 主/从 |
\
+ 同步文档 | ' + rdata.setName + ' | 文档名 |
\
+ primary | ' + rdata.primary + ' | primary |
\
+ me | ' + rdata.me + ' | me |
\
+ \
+
\
+
';
+
+ $(".soft-man-con").html(con);
+ },'json');
+}
+
+
+
+
+