Skip to content

Instantly share code, notes, and snippets.

@kgorman
Created June 13, 2013 17:19
Show Gist options
  • Save kgorman/5775530 to your computer and use it in GitHub Desktop.
Save kgorman/5775530 to your computer and use it in GitHub Desktop.
balance_check
var balance_check = function(n) {
if ( n ) {
var output = db.chunks.aggregate([
{ $group : { _id : { "_id":"$ns", "shard":"$shard" }, chunks : { $sum : 1 } }},
{ $match : { "_id._id" : n } },
{ $sort : { "chunks" : 1 } }
]);
} else {
var output = db.chunks.aggregate([
{ $group : { _id : { "_id":"$ns", "shard":"$shard" }, chunks : { $sum : 1 } }},
{ $sort : { "chunks" : 1 } }
]);
}
printjson(output);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment