ceph: Support the Octopus+ mgrmap format.

This commit is contained in:
Joshua Baergen 2022-04-12 08:51:09 -06:00
parent 4e0f8910a4
commit ebd166be2d
2 changed files with 44 additions and 4 deletions

View File

@ -1041,6 +1041,11 @@ type cephHealthStats struct {
} `json:"pgs_by_state"`
} `json:"pgmap"`
MgrMap struct {
// Octopus+ fields
Available bool `json:"available"`
NumStandBys int `json:"num_standbys"`
// Nautilus fields
ActiveName string `json:"active_name"`
StandBys []struct {
Name string `json:"name"`
@ -1382,12 +1387,21 @@ func (c *ClusterHealthCollector) collect(ch chan<- prometheus.Metric) error {
c.MisplacedRatio.Set(stats.PGMap.MisplacedRatio)
activeMgr := 0
if len(stats.MgrMap.ActiveName) > 0 {
activeMgr = 1
standByMgrs := 0
if c.version.IsAtLeast(Octopus) {
if stats.MgrMap.Available {
activeMgr = 1
}
standByMgrs = stats.MgrMap.NumStandBys
} else {
if len(stats.MgrMap.ActiveName) > 0 {
activeMgr = 1
}
standByMgrs = len(stats.MgrMap.StandBys)
}
c.MgrsActive.Set(float64(activeMgr))
c.MgrsNum.Set(float64(activeMgr + len(stats.MgrMap.StandBys)))
c.MgrsNum.Set(float64(activeMgr + standByMgrs))
for name, data := range stats.ServiceMap.Services.RbdMirror.Daemons {
if name == "summary" {

View File

@ -657,7 +657,8 @@ $ sudo ceph -s
},
},
{
name: "manager map",
name: "manager map",
versions: nautilusOnly,
input: `
{
"mgrmap": {
@ -700,6 +701,31 @@ $ sudo ceph -s
"dashboard": "http://mon01:7000/"
}
}
}`,
reMatch: []*regexp.Regexp{
regexp.MustCompile(`mgrs_active{cluster="ceph"} 1`),
regexp.MustCompile(`mgrs{cluster="ceph"} 3`),
},
},
{
name: "manager map",
versions: octopusPlus,
input: `
{
"mgrmap": {
"available": true,
"num_standbys": 2,
"modules": [
"iostat",
"pg_autoscaler",
"prometheus",
"restful"
],
"services": {
"prometheus": "http://10.117.16.32:9283/",
"restful": "https://10.117.16.32:8003/"
}
}
}`,
reMatch: []*regexp.Regexp{
regexp.MustCompile(`mgrs_active{cluster="ceph"} 1`),