Use optimeDate to get MongoTimestamp (mongo input plugin). (#1281)
This commit is contained in:
parent
c2797c85d1
commit
ca504a19ec
|
@ -33,7 +33,7 @@ func (s *Server) gatherData(acc telegraf.Accumulator) error {
|
||||||
result_repl := &ReplSetStatus{}
|
result_repl := &ReplSetStatus{}
|
||||||
err = s.Session.DB("admin").Run(bson.D{{"replSetGetStatus", 1}}, result_repl)
|
err = s.Session.DB("admin").Run(bson.D{{"replSetGetStatus", 1}}, result_repl)
|
||||||
if err != nil {
|
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()
|
jumbo_chunks, _ := s.Session.DB("config").C("chunks").Find(bson.M{"jumbo": true}).Count()
|
||||||
|
|
|
@ -78,9 +78,9 @@ type ReplSetStatus struct {
|
||||||
|
|
||||||
// ReplSetMember stores information related to a replica set member
|
// ReplSetMember stores information related to a replica set member
|
||||||
type ReplSetMember struct {
|
type ReplSetMember struct {
|
||||||
Name string `bson:"name"`
|
Name string `bson:"name"`
|
||||||
State int64 `bson:"state"`
|
State int64 `bson:"state"`
|
||||||
Optime *bson.MongoTimestamp `bson:"optime"`
|
OptimeDate *bson.MongoTimestamp `bson:"optimeDate"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// WiredTiger stores information related to the WiredTiger storage engine.
|
// 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
|
// 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 {
|
if lag < 0 {
|
||||||
returnVal.ReplLag = 0
|
returnVal.ReplLag = 0
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue