Use optimeDate to get MongoTimestamp (mongo input plugin). (#1281)

This commit is contained in:
Björn Lichtblau 2016-05-27 12:57:17 +02:00 committed by Cameron Sparr
parent c2797c85d1
commit ca504a19ec
2 changed files with 6 additions and 6 deletions

View File

@ -33,7 +33,7 @@ func (s *Server) gatherData(acc telegraf.Accumulator) error {
result_repl := &ReplSetStatus{}
err = s.Session.DB("admin").Run(bson.D{{"replSetGetStatus", 1}}, result_repl)
if err != nil {
log.Println("Not gathering replica set status, member not in replica set")
log.Println("Not gathering replica set status, member not in replica set (" + err.Error() + ")")
}
jumbo_chunks, _ := s.Session.DB("config").C("chunks").Find(bson.M{"jumbo": true}).Count()

View File

@ -78,9 +78,9 @@ type ReplSetStatus struct {
// ReplSetMember stores information related to a replica set member
type ReplSetMember struct {
Name string `bson:"name"`
State int64 `bson:"state"`
Optime *bson.MongoTimestamp `bson:"optime"`
Name string `bson:"name"`
State int64 `bson:"state"`
OptimeDate *bson.MongoTimestamp `bson:"optimeDate"`
}
// WiredTiger stores information related to the WiredTiger storage engine.
@ -663,9 +663,9 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec
}
}
if me.Optime != nil && master.Optime != nil && me.State == 2 {
if me.OptimeDate != nil && master.OptimeDate != nil && me.State == 2 {
// MongoTimestamp type is int64 where the first 32bits are the unix timestamp
lag := int64(*master.Optime>>32 - *me.Optime>>32)
lag := int64(*master.OptimeDate>>32 - *me.OptimeDate>>32)
if lag < 0 {
returnVal.ReplLag = 0
} else {