I am trying to get the results of the db.stats () mongo shell command in my Python code (for monitoring purposes).
But unlike, for example, serverStatus, I cannot do db.command('stats')
. I could not find the equivalent of the API in mongodb docs. I also tried options with db.$cmd
, but none of this worked.
So,
A small question: how can I get the results of db.stats()
(number of connections / objects, size of data and indexes, etc.) in my python code?
The big question is: can someone explain why some shell commands are easily accessible from the API and others not? This is very annoying: some admin-related tools are available through db.$cmd.sys
, some through db.command
, some through ...? Is there any standard or explanation for this situation?
PS: mongodb 2.0.2, pymongo 2.1.0, python 2.7
source share