------get all the database collection
count at once:---------
db.getCollectionNames().map(function(colName){return {"columnName":colName,"count":db.getCollection(colName).count()}});
----The following script prints the
statistics for each database:----------
db._adminCommand("listDatabases").databases.forEach(function (d) {
mdb = db.getSiblingDB(d.name);
printjson(mdb.stats());
})
-----The following script prints the
statistics for each collection in each database:-----
db._adminCommand("listDatabases").databases.forEach(function (d) {
mdb = db.getSiblingDB(d.name);
mdb.getCollectionNames().forEach(function(c) {
s = mdb[c].stats();
printjson(s);
})
})
---------------------------------------------