File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -1165,8 +1165,8 @@ DBCollection.prototype.getShardDistribution = function() {
1165
1165
1166
1166
numChunks += chunks . length ;
1167
1167
1168
- var estChunkData = shardStats . size / chunks . length ;
1169
- var estChunkCount = Math . floor ( shardStats . count / chunks . length ) ;
1168
+ var estChunkData = ( chunks . length == 0 ) ? 0 : shardStats . size / chunks . length ;
1169
+ var estChunkCount = ( chunks . length == 0 ) ? 0 : Math . floor ( shardStats . count / chunks . length ) ;
1170
1170
1171
1171
print ( " data : " + sh . _dataFormat ( shardStats . size ) + " docs : " + shardStats . count +
1172
1172
" chunks : " + chunks . length ) ;
@@ -1180,8 +1180,10 @@ DBCollection.prototype.getShardDistribution = function() {
1180
1180
for ( var shard in stats . shards ) {
1181
1181
var shardStats = stats . shards [ shard ] ;
1182
1182
1183
- var estDataPercent = Math . floor ( shardStats . size / stats . size * 10000 ) / 100 ;
1184
- var estDocPercent = Math . floor ( shardStats . count / stats . count * 10000 ) / 100 ;
1183
+ var estDataPercent =
1184
+ ( stats . size == 0 ) ? 0 : ( Math . floor ( shardStats . size / stats . size * 10000 ) / 100 ) ;
1185
+ var estDocPercent =
1186
+ ( stats . count == 0 ) ? 0 : ( Math . floor ( shardStats . count / stats . count * 10000 ) / 100 ) ;
1185
1187
1186
1188
print ( " Shard " + shard + " contains " + estDataPercent + "% data, " + estDocPercent +
1187
1189
"% docs in cluster, " + "avg obj size on shard : " +
Original file line number Diff line number Diff line change @@ -29,6 +29,10 @@ sh._getBalancerStatus = function() {
29
29
} ;
30
30
31
31
sh . _dataFormat = function ( bytes ) {
32
+ if ( bytes == null ) {
33
+ return "0B" ;
34
+ }
35
+
32
36
if ( bytes < 1024 )
33
37
return Math . floor ( bytes ) + "B" ;
34
38
if ( bytes < 1024 * 1024 )
You can’t perform that action at this time.
0 commit comments