This file contains 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.adminCommand({'listDatabases':1, nameOnly:true}).databases.forEach(function(mydb) { | |
var dbName = mydb.name; | |
if (! ["admin", "config", "local"].includes(dbName)) { | |
var currentDB = db.getSiblingDB(dbName); | |
var collectionNames = currentDB.getCollectionNames(); | |
collectionNames.forEach(function (collName) { | |
if (/^system\./.test(collName)){ | |
return; | |
} | |
var indexes = currentDB[collName].getIndexes(); |
This file contains 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
/* global db, tojson, tojsononeline, rs, print, printjson */ | |
/* ================================================= | |
* getMongoData.js: MongoDB Config and Schema Report | |
* ================================================= | |
* | |
* Copyright MongoDB, Inc, 2015 | |
* | |
* Gather MongoDB configuration and schema information. | |
* |
This file contains 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.adminCommand( { listDatabases: 1 } ).databases.forEach(function (dbObj) { | |
var stats = db.getSiblingDB(dbObj["name"]).stats(); | |
if (stats.objects == 0) { | |
print(dbObj["name"]); | |
} | |
}); |
This file contains 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 dbCount = 0; | |
var collCount = 0; | |
var dataSize = 0; | |
var storageSize = 0; | |
var indexSize = 0; | |
db.adminCommand( { listDatabases: 1 } ).databases.forEach(function (dbObj) { | |
var stats = db.getSiblingDB(dbObj["name"]).stats(1024*1024*1024); | |
dbCount++; | |
collCount += stats.collections; | |
dataSize += stats.dataSize; |
This file contains 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
mongo --quiet --eval 'db.adminCommand( { listDatabases: 1 } ).databases.forEach(function (dbObj) {printjson(db.getSiblingDB(dbObj["name"]).stats(1024*1024*1024));});' |
This file contains 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 = db.getSiblingDB("admin"); | |
dbs = db.runCommand({ "listDatabases": 1 }).databases; | |
dbs.forEach(function(database) { | |
db = db.getSiblingDB(database.name); | |
cols = db.getCollectionNames(); | |
cols.forEach(function(col) { | |
print(`*** ${col} ***`); | |
printjson(db.getCollection(col).getIndexes()); | |
}); | |
}); |
This file contains 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
// Number of chars of the first two groups (most-significant) in UUID string | |
var UUIDHeadChars = 12; | |
// Max number of integers that can be represented using | |
var UUIDHeadMax = Math.pow(16, UUIDHeadChars); | |
function UUIDFromInt(num) { | |
assert(num < UUIDHeadMax); | |
// Format num as hexadecimal string with enough left-zero-padding | |
// to reach UUIDHeadChars |
This file contains 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.adminCommand( { listDatabases: 1 } ).databases.forEach(function (dbObj) { | |
var dbName = dbObj["name"]; | |
if (dbName != null) { | |
var collectionNames = db.getSiblingDB(dbName).getCollectionNames(); | |
collectionNames.forEach(function (collName) { | |
if (collName != null) { | |
var count = db.getSiblingDB(dbName).getCollection(collName).count(); | |
print(`${dbName}.${collName}: ${count}`) | |
} | |
}); |
This file contains 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.getCollectionNames().forEach(function(coll) { | |
var indexes = db[coll].getIndexes(); | |
indexes.forEach(function(ix) { | |
if (ix["expireAfterSeconds"] !== undefined) { | |
print(`${ix.ns} ${ix["expireAfterSeconds"]}`); | |
var collName = ix.ns.split('.')[1]; | |
var mod = db.runCommand({ | |
"collMod": collName, | |
"index": { | |
name: ix.name, |
This file contains 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
[Unit] | |
Description=Disable Transparent Huge Pages (THP) | |
DefaultDependencies=no | |
After=sysinit.target local-fs.target | |
Before=mongod.service | |
[Service] | |
Type=oneshot | |
ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/enabled > /dev/null' | |
ExecStart=/bin/sh -c 'echo never | tee /sys/kernel/mm/transparent_hugepage/defrag > /dev/null' |
NewerOlder