本文介绍了pymongo的MongoDB WorkingSet的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过pymongo获取"workingSet"指标.在MongoDB中只是db.runCommand( { serverStatus: 1, workingSet: 1 } ).我已经在python

I try to get "workingSet" metrics with pymongo. In MongoDB is just db.runCommand( { serverStatus: 1, workingSet: 1 } ). I've tried in python

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

我的方法行不通.它的输出不是任何"workingSet"指标.

My approach doesn't work. It the output isn't any "workingSet" metrics.

有什么主意,我该如何在python中以编程方式获取这些指标?

Any idea how i can get those metrics programmatically in python?

推荐答案

>>> 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}

这篇关于pymongo的MongoDB WorkingSet的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 02:32