From 61e8e0528953466c5d10c896010bf6d0d5f342ca Mon Sep 17 00:00:00 2001 From: midoks Date: Fri, 26 Nov 2021 22:00:16 +0800 Subject: [PATCH] up --- plugins/mongodb/index.html | 24 +++++++++++++++++++++++- plugins/mongodb/index.py | 12 +++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/plugins/mongodb/index.html b/plugins/mongodb/index.html index 5adf23d95..ebe9c50cf 100755 --- a/plugins/mongodb/index.html +++ b/plugins/mongodb/index.html @@ -37,7 +37,29 @@ function redisStatus() { connections' + rdata.connections + '当前链接数\ collections' + rdata.collections + '文档数\ \ - ' +
'; + + var t = ''; + for(var i=0; i'; + t += ''+toSize(rdata.dbs[i]["totalSize"])+''; + t += ''+toSize(rdata.dbs[i]["storageSize"])+''; + t += ''+toSize(rdata.dbs[i]["dataSize"])+''; + t += ''+toSize(rdata.dbs[i]["indexSize"])+''; + t += ''+rdata.dbs[i]["indexes"]+''; + t += ''+rdata.dbs[i]["objects"]+''; + t += ''; + } + // console.log(t); + + Con += '
\ + \ + \ + '+t+'\ +
库名大小存储大小数据索引文档数据对象
'; + // console.log(rdata.dbs); + $(".soft-man-con").html(Con); },'json'); } diff --git a/plugins/mongodb/index.py b/plugins/mongodb/index.py index be3cb5c69..ea6bfd534 100755 --- a/plugins/mongodb/index.py +++ b/plugins/mongodb/index.py @@ -148,9 +148,18 @@ def runInfo(): client = pymongo.MongoClient(host='127.0.0.1', port=27017) db = client.admin serverStatus = db.command('serverStatus') + + listDbs = client.list_database_names() + + showDbList = [] + for x in range(len(listDbs)): + mongd = client[listDbs[x]] + stats = mongd.command({"dbstats": 1}) + showDbList.append(stats) + # print(showDbList) # print(serverStatus) # for key, value in serverStatus.items(): - # print(key, value) + # print(key, value) result = {} result["version"] = serverStatus['version'] result["uptime"] = serverStatus['uptime'] @@ -162,6 +171,7 @@ def runInfo(): result["connections"] = serverStatus['connections']['current'] result["collections"] = serverStatus['catalogStats']['collections'] + result["dbs"] = showDbList return mw.getJson(result)