Commit 1a5e08ae by Kevin Falcone

Log collection stats for certain mongos

parent 4f8686bd
......@@ -40,6 +40,7 @@ MONGO_USERS:
roles: readWrite
MONGO_CLUSTERED: !!null
MONGO_LOG_COLLECTION_STATS: !!null
MONGO_BIND_IP: 127.0.0.1
MONGO_REPL_SET: "rs0"
......
#!/usr/bin/env bash
# Using JSON.stringify forces output of normal JSON, as opposed to Mongo's weird non-compliant extended JSON
/usr/bin/mongo -u {{ MONGO_ADMIN_USER }} --authenticationDatabase admin -p '{{ MONGO_ADMIN_PASSWORD }}' --quiet <<< 'JSON.stringify(db.serverStatus())'
# This can generate a lot more logging, so only turn it on for environments
# where you're interested in collection-level statistics
{% if MONGO_LOG_COLLECTION_STATS %}
/usr/bin/mongo -u {{ MONGO_ADMIN_USER }} --authenticationDatabase admin -p '{{ MONGO_ADMIN_PASSWORD }}' --quiet <<< '
rs.slaveOk();
db.getMongo().getDBNames().forEach(function(database) {
if (/^(local|admin)/.test(database))
return;
thisdb = db.getSiblingDB(database);
thisdb.getCollectionNames().forEach(function(collection) {print(JSON.stringify(thisdb[collection].stats()))});
});
'
{% endif %}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment