health/pgs: track misplaced objects from their pgs

This commit is contained in:
Vaibhav Bhembre 2016-02-08 19:15:33 +00:00
parent bd2206ffbb
commit 498d7ff177
2 changed files with 51 additions and 10 deletions

View File

@ -69,6 +69,12 @@ type ClusterHealthCollector struct {
// DegradedObjectsCount gives the no. of RADOS objects are constitute the degraded PGs.
DegradedObjectsCount prometheus.Gauge
// MisplacedObjectsCount gives the no. of RADOS objects that constitute the misplaced PGs.
// Misplaced PGs usually represent the PGs that are not in the storage locations that
// they should be in. This is different than degraded PGs which means a PG has fewer copies
// that it should.
MisplacedObjectsCount prometheus.Gauge
// OSDsDown show the no. of OSDs that are in the DOWN state.
OSDsDown prometheus.Gauge
@ -174,6 +180,13 @@ func NewClusterHealthCollector(conn Conn) *ClusterHealthCollector {
Help: "No. of degraded objects across all PGs",
},
),
MisplacedObjectsCount: prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: cephNamespace,
Name: "misplaced_objects",
Help: "No. of misplaced objects across all PGs",
},
),
OSDsDown: prometheus.NewGauge(
prometheus.GaugeOpts{
Namespace: cephNamespace,
@ -224,6 +237,7 @@ func (c *ClusterHealthCollector) metricsList() []prometheus.Metric {
c.StalePGs,
c.StuckStalePGs,
c.DegradedObjectsCount,
c.MisplacedObjectsCount,
c.OSDsDown,
c.OSDsUp,
c.OSDsIn,
@ -280,16 +294,17 @@ func (c *ClusterHealthCollector) collect() error {
}
var (
degradedRegex = regexp.MustCompile(`([\d]+) pgs degraded`)
stuckDegradedRegex = regexp.MustCompile(`([\d]+) pgs stuck degraded`)
uncleanRegex = regexp.MustCompile(`([\d]+) pgs unclean`)
stuckUncleanRegex = regexp.MustCompile(`([\d]+) pgs stuck unclean`)
undersizedRegex = regexp.MustCompile(`([\d]+) pgs undersized`)
stuckUndersizedRegex = regexp.MustCompile(`([\d]+) pgs stuck undersized`)
staleRegex = regexp.MustCompile(`([\d]+) pgs stale`)
stuckStaleRegex = regexp.MustCompile(`([\d]+) pgs stuck stale`)
degradedObjectsRegex = regexp.MustCompile(`recovery ([\d]+)/([\d]+) objects degraded`)
osdsDownRegex = regexp.MustCompile(`([\d]+)/([\d]+) in osds are down`)
degradedRegex = regexp.MustCompile(`([\d]+) pgs degraded`)
stuckDegradedRegex = regexp.MustCompile(`([\d]+) pgs stuck degraded`)
uncleanRegex = regexp.MustCompile(`([\d]+) pgs unclean`)
stuckUncleanRegex = regexp.MustCompile(`([\d]+) pgs stuck unclean`)
undersizedRegex = regexp.MustCompile(`([\d]+) pgs undersized`)
stuckUndersizedRegex = regexp.MustCompile(`([\d]+) pgs stuck undersized`)
staleRegex = regexp.MustCompile(`([\d]+) pgs stale`)
stuckStaleRegex = regexp.MustCompile(`([\d]+) pgs stuck stale`)
degradedObjectsRegex = regexp.MustCompile(`recovery ([\d]+)/([\d]+) objects degraded`)
misplacedObjectsRegex = regexp.MustCompile(`recovery ([\d]+)/([\d]+) objects misplaced`)
osdsDownRegex = regexp.MustCompile(`([\d]+)/([\d]+) in osds are down`)
)
for _, s := range stats.Health.Summary {
@ -374,6 +389,15 @@ func (c *ClusterHealthCollector) collect() error {
c.DegradedObjectsCount.Set(float64(v))
}
matched = misplacedObjectsRegex.FindStringSubmatch(s.Summary)
if len(matched) == 3 {
v, err := strconv.Atoi(matched[1])
if err != nil {
return err
}
c.MisplacedObjectsCount.Set(float64(v))
}
matched = osdsDownRegex.FindStringSubmatch(s.Summary)
if len(matched) == 3 {
v, err := strconv.Atoi(matched[1])

View File

@ -184,6 +184,23 @@ func TestClusterHealthCollector(t *testing.T) {
},
{
input: `
{
"osdmap": {
"osdmap": {
"num_osds": 0,
"num_up_osds": 0,
"num_in_osds": 0,
"num_remapped_pgs": 0
}
},
"health": {"summary": [{"severity": "HEALTH_WARN", "summary": "recovery 20/40 objects misplaced"}]}
}`,
regexes: []*regexp.Regexp{
regexp.MustCompile(`misplaced_objects 20`),
},
},
{
input: `
{
"osdmap": {
"osdmap": {