Skip collection stats when disabled in mongodb input (#6364)

This commit is contained in:
Daniel Nelson
2019-09-09 15:55:46 -07:00
committed by GitHub
parent 23cddef30a
commit a4078da648
4 changed files with 31 additions and 21 deletions

View File

@@ -961,24 +961,25 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec
}
}
newColStats := *newMongo.ColStats
for _, col := range newColStats.Collections {
colStatsData := col.ColStatsData
// mongos doesn't have the db key, so setting the db name
if colStatsData.Collection == "" {
colStatsData.Collection = col.Name
if newMongo.ColStats != nil {
for _, col := range newMongo.ColStats.Collections {
colStatsData := col.ColStatsData
// mongos doesn't have the db key, so setting the db name
if colStatsData.Collection == "" {
colStatsData.Collection = col.Name
}
colStatLine := &ColStatLine{
Name: colStatsData.Collection,
DbName: col.DbName,
Count: colStatsData.Count,
Size: colStatsData.Size,
AvgObjSize: colStatsData.AvgObjSize,
StorageSize: colStatsData.StorageSize,
TotalIndexSize: colStatsData.TotalIndexSize,
Ok: colStatsData.Ok,
}
returnVal.ColStatsLines = append(returnVal.ColStatsLines, *colStatLine)
}
colStatLine := &ColStatLine{
Name: colStatsData.Collection,
DbName: col.DbName,
Count: colStatsData.Count,
Size: colStatsData.Size,
AvgObjSize: colStatsData.AvgObjSize,
StorageSize: colStatsData.StorageSize,
TotalIndexSize: colStatsData.TotalIndexSize,
Ok: colStatsData.Ok,
}
returnVal.ColStatsLines = append(returnVal.ColStatsLines, *colStatLine)
}
// Set shard stats