bingtuag 发表于 2018-10-26 08:55:13

MongoDB服务端JavaScript脚本

db.system.js.remove({"_id":"dbaStatCollections"});  

  
db.system.js.save(
  
{
  
    _id : "dbaStatCollections" ,
  
    value : function () {
  
      collNames = db.getCollectionNames();
  
      for (var index = 0; index < collNames.length; index++) {
  
            var coll = db.getCollection(collNames);
  
            var stats = coll.stats();
  
            print('ns,count,size,totalIndexSize');
  
            print(stats.ns + ',' + stats.count + ',' + stats.size + ',' + stats.totalIndexSize);
  
      }
  
    }
  
}
  
);
  

  
db.loadServerScripts();
  

  
dbaStatCollections();


页: [1]
查看完整版本: MongoDB服务端JavaScript脚本