我尝试用pymongo获取“workingSet”指标。在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
我的方法不起作用。它的输出不是任何“workingSet”指标。
知道如何在python中以编程方式获取这些指标吗?
答案 0 :(得分:4)
>>> 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}