获取stats
from pymongo import MongoClient client = MongoClient() db = client.test # print collection statistics print db.command("collstats", "events") print(db.command("collstats", "messages")["storageSize"])
# print database statistics print db.command("dbstats")