pymong提供的MongoDB工作集

2024-06-26 17:51:59 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试用pymongo获得“工作集”指标。在MongoDB中只是db.runCommand( { serverStatus: 1, workingSet: 1 } )。我试过python

from pymongo.mongo_client import MongoClient
connection = MongoClient('localhost', 27017)
db = connection['admin']
workingSetMetrics = db.command("serverStatus", "workingSet")
print 'workingSetMetrics: ', workingSetMetrics

我的方法行不通。它的输出不是任何“工作集”指标。在

知道如何用python编程获得这些度量吗?在


Tags: fromimportclientlocalhostdbmongomongodbconnection
1条回答
网友
1楼 · 发布于 2024-06-26 17:51:59
>>> import pymongo
>>> c = pymongo.MongoClient()
>>> c['admin'].command('serverStatus', workingSet=True)['workingSet']
{u'note': u'thisIsAnEstimate', u'computationTimeMicros': 4555, u'pagesInMemory': 7, u'overSeconds': 388}

相关问题 更多 >