This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getStorageDetails() { | |
| var db = this.db.getSiblingDB("admin"); | |
| var totalIndexSize = 0, | |
| totalStorageSize = 0, | |
| totalDataSize = 0, | |
| formatSize = 1024 * 1024 * 1024; | |
| // List the databases | |
| var dbs = db.runCommand({ listDatabases: 1 }); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var colls = db.getCollectionNames(); | |
| var ret = []; | |
| colls.forEach(function(coll) { | |
| var stats = db.getCollection(coll).stats(); | |
| ret.push({ "name": coll, "stats": stats}); | |
| }) | |
| printjson(ret) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const MongoClient = require("mongodb").MongoClient; | |
| const { LoremIpsum } = require("lorem-ipsum"); | |
| const cluster = require('cluster'); | |
| const MONGOURI = "MONGO_URI"; | |
| const DB = "test_db"; | |
| const COLL = "test_coll"; | |
| /* Lorem Ipsum Generator */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| db.currentOp(true).inprog.reduce( | |
| (accumulator, connection) => { | |
| ipaddress = connection.client ? connection.client.split(":")[0] : "Internal"; | |
| accumulator[ipaddress] = (accumulator[ipaddress] || 0) + 1; | |
| accumulator["TOTAL_CONNECTION_COUNT"]++; | |
| return accumulator; | |
| }, | |
| { TOTAL_CONNECTION_COUNT: 0 } | |
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getStorageDetails() { | |
| var db = this.db.getSiblingDB("admin"); | |
| var totalIndexSize = 0, | |
| totalStorageSize = 0, | |
| totalDataSize = 0, | |
| formatSize = 1024 * 1024 * 1024; | |
| // List the databases | |
| var dbs = db.runCommand({ listDatabases: 1 }).databases; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var colls = db.getCollectionNames(); | |
| var ret = []; | |
| colls.forEach(function(coll) { | |
| var indexes = db.getCollection(coll).getIndexes(); | |
| var len = indexes.length | |
| if (len >= 10) { | |
| ret.push({ "name": coll, "length": len, "data": indexes}); | |
| } | |
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getStorageDetails() { | |
| var db = this.db.getSiblingDB("admin"); | |
| var totalIndexSize = 0, | |
| totalStorageSize = 0, | |
| totalDataSize = 0, | |
| formatSize = 1024 * 1024 * 1024; | |
| // List the databases | |
| var dbs = db.runCommand({ listDatabases: 1 }).databases; | |
NewerOlder