Skip to content

Commit

Permalink
fix missing thresholds when using perf-syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Oct 18, 2024
1 parent 8992fc9 commit b9655ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ next:
- add /api/v1/admin/updates/install endpoint to trigger update
- fix agent not starting if exporter_modules folder does not exist
- check_files: add version macro support for .exe/.dll files
- fix missing thresholds when using perf-syntax

0.27 Mon Sep 2 19:31:14 CEST 2024
- do not use empty-state if warn/crit conditions contain check on 'count'
Expand Down
4 changes: 4 additions & 0 deletions pkg/snclient/checkresult.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ func (cr *CheckResult) ApplyPerfSyntax(perfSyntax string) {
macros := map[string]string{
"key": metric.Name,
}
// save original name, so thresholds can be added properly later
if metric.ThresholdName == "" {
metric.ThresholdName = metric.Name
}
metric.Name = ReplaceMacros(perfSyntax, macros)
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/snclient/perfconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func TestCheckPerfSyntax(t *testing.T) {
})
assert.Equalf(t, CheckExitOK, res.State, "state OK")
assert.Regexpf(t,
regexp.MustCompile(`'mem:PHYSICAL %'=`),
regexp.MustCompile(`'mem:PHYSICAL %'=[\d\.]+%;101;102;0;100`),

Check failure on line 94 in pkg/snclient/perfconfig_test.go

View workflow job for this annotation

GitHub Actions / test

regexpSimplify: can re-write `'mem:PHYSICAL %'=[\d\.]+%;101;102;0;100` as `'mem:PHYSICAL %'=[\d.]+%;101;102;0;100` (gocritic)
string(res.BuildPluginOutput()),
"output matches",
)
Expand Down

0 comments on commit b9655ee

Please sign in to comment.