fix: solve compatibility issue for mongodb inputs when using 5.x relicaset (#9892)
This commit is contained in:
parent
aaaaabd0fd
commit
34c2b6232d
|
|
@ -248,14 +248,15 @@ type TransactionStats struct {
|
|||
|
||||
// ReplStatus stores data related to replica sets.
|
||||
type ReplStatus struct {
|
||||
SetName string `bson:"setName"`
|
||||
IsMaster interface{} `bson:"ismaster"`
|
||||
Secondary interface{} `bson:"secondary"`
|
||||
IsReplicaSet interface{} `bson:"isreplicaset"`
|
||||
ArbiterOnly interface{} `bson:"arbiterOnly"`
|
||||
Hosts []string `bson:"hosts"`
|
||||
Passives []string `bson:"passives"`
|
||||
Me string `bson:"me"`
|
||||
SetName string `bson:"setName"`
|
||||
IsWritablePrimary interface{} `bson:"isWritablePrimary"` // mongodb 5.x
|
||||
IsMaster interface{} `bson:"ismaster"`
|
||||
Secondary interface{} `bson:"secondary"`
|
||||
IsReplicaSet interface{} `bson:"isreplicaset"`
|
||||
ArbiterOnly interface{} `bson:"arbiterOnly"`
|
||||
Hosts []string `bson:"hosts"`
|
||||
Passives []string `bson:"passives"`
|
||||
Me string `bson:"me"`
|
||||
}
|
||||
|
||||
// DBRecordStats stores data related to memory operations across databases.
|
||||
|
|
@ -1165,11 +1166,13 @@ func NewStatLine(oldMongo, newMongo MongoStatus, key string, all bool, sampleSec
|
|||
if newStat.Repl != nil {
|
||||
returnVal.ReplSetName = newStat.Repl.SetName
|
||||
// BEGIN code modification
|
||||
if newStat.Repl.IsMaster.(bool) {
|
||||
if val, ok := newStat.Repl.IsMaster.(bool); ok && val {
|
||||
returnVal.NodeType = "PRI"
|
||||
} else if newStat.Repl.Secondary != nil && newStat.Repl.Secondary.(bool) {
|
||||
} else if val, ok := newStat.Repl.IsWritablePrimary.(bool); ok && val {
|
||||
returnVal.NodeType = "PRI"
|
||||
} else if val, ok := newStat.Repl.Secondary.(bool); ok && val {
|
||||
returnVal.NodeType = "SEC"
|
||||
} else if newStat.Repl.ArbiterOnly != nil && newStat.Repl.ArbiterOnly.(bool) {
|
||||
} else if val, ok := newStat.Repl.ArbiterOnly.(bool); ok && val {
|
||||
returnVal.NodeType = "ARB"
|
||||
} else {
|
||||
returnVal.NodeType = "UNK"
|
||||
|
|
|
|||
Loading…
Reference in New Issue