Skip to content

Commit

Permalink
Skip NODE mmhealth status if filtering out releated event (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
treydock authored Jul 5, 2023
1 parent 70762b9 commit ae24f74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
4 changes: 4 additions & 0 deletions collectors/mmhealth.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func mmhealth_parse(out string, logger log.Logger) []HealthMetric {
if metric.Type == "Event" {
if *mmhealthIgnoredEvent != "" && mmhealthIgnoredEventPattern.MatchString(metric.Event) {
events = append(events, fmt.Sprintf("%s-%s-%s", metric.Component, metric.EntityName, metric.EntityType))
events = append(events, fmt.Sprintf("%s-%s", metric.EntityName, metric.EntityType))
}
} else {
metrics = append(metrics, metric)
Expand All @@ -214,6 +215,9 @@ func mmhealth_parse(out string, logger log.Logger) []HealthMetric {
if SliceContains(events, key) {
continue
}
if m.Component == "NODE" && SliceContains(events, fmt.Sprintf("%s-%s", m.EntityName, m.EntityType)) {
continue
}
finalMetrics = append(finalMetrics, m)
}
return finalMetrics
Expand Down
23 changes: 18 additions & 5 deletions collectors/mmhealth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ mmhealth:Event:HEADER:version:reserved:reserved:node:component:entityname:entity
mmhealth:State:HEADER:version:reserved:reserved:node:component:entityname:entitytype:status:laststatuschange:
mmhealth:State:0:1:::ib-haswell1.example.com:NODE:ib-haswell1.example.com:NODE:TIPS:2020-01-27 09%3A35%3A21.859186 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:GPFS:ib-haswell1.example.com:NODE:TIPS:2020-01-27 09%3A35%3A21.791895 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:NETWORK:ib-haswell1.example.com:NODE:HEALTHY:2020-01-07 17%3A02%3A40.131272 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:NETWORK:ib0:NIC:HEALTHY:2020-01-07 16%3A47%3A39.397852 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:NETWORK:mlx5_0/1:IB_RDMA:FOO:2020-01-07 17%3A02%3A40.205075 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:FILESYSTEM:ib-haswell1.example.com:NODE:HEALTHY:2020-01-27 09%3A35%3A21.499264 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:FILESYSTEM:project:FILESYSTEM:HEALTHY:2020-01-27 09%3A35%3A21.573978 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:FILESYSTEM:scratch:FILESYSTEM:HEALTHY:2020-01-27 09%3A35%3A21.657798 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:FILESYSTEM:ess:FILESYSTEM:HEALTHY:2020-01-27 09%3A35%3A21.716417 EST:
`
mmhealthStdoutEvent = `
mmhealth:Event:HEADER:version:reserved:reserved:node:component:entityname:entitytype:event:arguments:activesince:identifier:ishidden:
mmhealth:State:HEADER:version:reserved:reserved:node:component:entityname:entitytype:status:laststatuschange:
mmhealth:State:0:1:::ib-haswell1.example.com:NODE:ib-haswell1.example.com:NODE:TIPS:2020-01-27 09%3A35%3A21.859186 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:GPFS:ib-haswell1.example.com:NODE:TIPS:2020-01-27 09%3A35%3A21.791895 EST:
mmhealth:Event:0:1:::ib-haswell1.example.com:GPFS:ib-haswell1.example.com:NODE:gpfs_pagepool_small::2020-01-07 16%3A47%3A43.892296 EST::no:
mmhealth:State:0:1:::ib-haswell1.example.com:NETWORK:ib-haswell1.example.com:NODE:HEALTHY:2020-01-07 17%3A02%3A40.131272 EST:
mmhealth:State:0:1:::ib-haswell1.example.com:NETWORK:ib0:NIC:HEALTHY:2020-01-07 16%3A47%3A39.397852 EST:
Expand Down Expand Up @@ -126,17 +139,17 @@ func TestParseMmhealthIgnores(t *testing.T) {
mmhealthIgnoredEntityName = &noignore
mmhealthIgnoredEntityType = &noignore
mmhealthIgnoredEvent = &eventIgnore
metrics := mmhealth_parse(mmhealthStdout, log.NewNopLogger())
if len(metrics) != 4 {
t.Errorf("Expected 4 metrics returned, got %d", len(metrics))
metrics := mmhealth_parse(mmhealthStdoutEvent, log.NewNopLogger())
if len(metrics) != 3 {
t.Errorf("Expected 3 metrics returned, got %d", len(metrics))
return
}
ignore = "ess"
mmhealthIgnoredComponent = &noignore
mmhealthIgnoredEntityName = &ignore
mmhealthIgnoredEntityType = &noignore
mmhealthIgnoredEvent = &empty
metrics = mmhealth_parse(mmhealthStdout, log.NewNopLogger())
metrics = mmhealth_parse(mmhealthStdoutEvent, log.NewNopLogger())
if len(metrics) != 8 {
t.Errorf("Expected 8 metrics returned, got %d", len(metrics))
return
Expand All @@ -146,7 +159,7 @@ func TestParseMmhealthIgnores(t *testing.T) {
mmhealthIgnoredEntityName = &noignore
mmhealthIgnoredEntityType = &ignore
mmhealthIgnoredEvent = &empty
metrics = mmhealth_parse(mmhealthStdout, log.NewNopLogger())
metrics = mmhealth_parse(mmhealthStdoutEvent, log.NewNopLogger())
if len(metrics) != 6 {
t.Errorf("Expected 6 metrics returned, got %d", len(metrics))
return
Expand Down

0 comments on commit ae24f74

Please sign in to comment.