summaryrefslogtreecommitdiff
path: root/src/mongo/shell/collection.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/shell/collection.js')
-rw-r--r--src/mongo/shell/collection.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mongo/shell/collection.js b/src/mongo/shell/collection.js
index 81c4d7dae5e..3d8b66451ff 100644
--- a/src/mongo/shell/collection.js
+++ b/src/mongo/shell/collection.js
@@ -1224,8 +1224,8 @@ DBCollection.prototype.getShardDistribution = function() {
numChunks += chunks.length;
- var estChunkData = shardStats.size / chunks.length;
- var estChunkCount = Math.floor(shardStats.count / chunks.length);
+ var estChunkData = (chunks.length == 0) ? 0 : shardStats.size / chunks.length;
+ var estChunkCount = (chunks.length == 0) ? 0 : Math.floor(shardStats.count / chunks.length);
print(" data : " + sh._dataFormat(shardStats.size) + " docs : " + shardStats.count +
" chunks : " + chunks.length);
@@ -1239,8 +1239,10 @@ DBCollection.prototype.getShardDistribution = function() {
for (var shard in stats.shards) {
var shardStats = stats.shards[shard];
- var estDataPercent = Math.floor(shardStats.size / stats.size * 10000) / 100;
- var estDocPercent = Math.floor(shardStats.count / stats.count * 10000) / 100;
+ var estDataPercent =
+ (stats.size == 0) ? 0 : (Math.floor(shardStats.size / stats.size * 10000) / 100);
+ var estDocPercent =
+ (stats.count == 0) ? 0 : (Math.floor(shardStats.count / stats.count * 10000) / 100);
print(" Shard " + shard + " contains " + estDataPercent + "% data, " + estDocPercent +
"% docs in cluster, " + "avg obj size on shard : " +