Skip to content

Commit 630587d

Browse files
author
Emilien Kenler
committed
Support priority for host rules
1 parent d3f654e commit 630587d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

collectd/checker.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,25 @@ func (checker *Checker) checkRecord(record CollectdRecord) ([]shared.CheckResult
8989
}
9090

9191
// Load host specific thresholds
92+
priority := 0
9293
for pattern, threshold := range rule.Check.HostThresholds {
9394
if threshold.Regexp == nil {
9495
continue
9596
}
9697

98+
if threshold.Priority < priority {
99+
continue
100+
}
101+
97102
if !threshold.Regexp.MatchString(record.Host) {
98103
continue
99104
}
100105

101106
matchName = fmt.Sprintf("host:%s", pattern)
102107

108+
priority = threshold.Priority
103109
critical = threshold.Critical
104110
warning = threshold.Warning
105-
break
106111
}
107112

108113
// CRITICAL CHECK

config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const (
2424
type CheckThreshold struct {
2525
WarningTpl string `hcl:"warning"`
2626
CriticalTpl string `hcl:"critical"`
27+
Priority int `hcl:"priority"`
2728
Warning hil.EvaluationResult `hcl:"-"`
2829
Critical hil.EvaluationResult `hcl:"-"`
2930
Regexp *regexp.Regexp `hcl:"-"`

0 commit comments

Comments
 (0)