Add shard server stats to the mongodb input plugin (#3808)

This commit is contained in:
Jake Champlin
2018-02-20 16:55:56 -05:00
committed by Daniel Nelson
parent 1fc8b2c71e
commit 3e31ae4eca
5 changed files with 68 additions and 1 deletions

View File

@@ -55,8 +55,18 @@ func (s *Server) gatherData(acc telegraf.Accumulator, gatherDbStats bool) error
JumboChunksCount: int64(jumbo_chunks),
}
result_db_stats := &DbStats{}
resultShards := &ShardStats{}
err = s.Session.DB("admin").Run(bson.D{
{
Name: "shardConnPoolStats",
Value: 1,
},
}, &resultShards)
if err != nil {
log.Println("E! Error getting database shard stats (" + err.Error() + ")")
}
result_db_stats := &DbStats{}
if gatherDbStats == true {
names := []string{}
names, err = s.Session.DatabaseNames()
@@ -88,6 +98,7 @@ func (s *Server) gatherData(acc telegraf.Accumulator, gatherDbStats bool) error
ReplSetStatus: result_repl,
ClusterStatus: result_cluster,
DbStats: result_db_stats,
ShardStats: resultShards,
}
defer func() {