From f8eb41846ca9772501191f8075b507b13d7d67f6 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Tue, 28 Apr 2026 23:53:13 +0200 Subject: [PATCH 1/2] check_process: add count of process(es) to the top syntax ok-synax is changed as well -> processes to process(es) for optional plularity ensures that that even when check result is warning/critical it will include the count: before: ./snclient run check_process "warning=count gt 500" WARNING - |'count'=9307;500;0;0 after: ./snclient run check_process "critical=count gt 500" CRITICAL - 9309 process(es) running |'count'=9309;0;500;0 --- pkg/snclient/check_process.go | 4 ++-- pkg/snclient/check_process_test.go | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/snclient/check_process.go b/pkg/snclient/check_process.go index 70fdc5a8..a7c35313 100644 --- a/pkg/snclient/check_process.go +++ b/pkg/snclient/check_process.go @@ -35,9 +35,9 @@ func (l *CheckProcess) Build() *CheckData { "timezone": {description: "Sets the timezone for time metrics (default is local time)"}, }, conditionAlias: l.buildConditionAlias(), - okSyntax: "%(status) - all %{count} processes are ok.", + okSyntax: "%(status) - all %{count} process(es) are ok.", detailSyntax: "${exe}=${state}", - topSyntax: "%(status) - ${problem_list}", + topSyntax: "%(status) - %{count} process(es) running ${problem_list}", emptyState: 2, emptySyntax: "%(status) - no processes found with this filter.", defaultWarning: "count = 0", diff --git a/pkg/snclient/check_process_test.go b/pkg/snclient/check_process_test.go index 70f1c42e..914f4f29 100644 --- a/pkg/snclient/check_process_test.go +++ b/pkg/snclient/check_process_test.go @@ -19,7 +19,7 @@ func TestCheckProcess(t *testing.T) { res := snc.RunCheck("check_process", []string{}) assert.Equalf(t, CheckExitOK, res.State, "state ok") - assert.Regexpf(t, `^OK - all \d+ processes are ok`, string(res.BuildPluginOutput()), "output matches") + assert.Regexpf(t, `^OK - all \d+ process\(es\) are ok`, string(res.BuildPluginOutput()), "output matches") assert.Regexpf(t, `'count'=\d+;0;0;0$`, string(res.BuildPluginOutput()), "perfdata ok") res = snc.RunCheck("check_process", []string{"process=noneexisting.exe"}) @@ -50,13 +50,13 @@ func TestCheckProcess(t *testing.T) { require.NoErrorf(t, err, "got own exe") res = snc.RunCheck("check_process", []string{"process=" + filepath.Base(myExe)}) assert.Equalf(t, CheckExitOK, res.State, "state ok") - assert.Regexpf(t, `OK - all \d+ processes are ok.`, string(res.BuildPluginOutput()), "output ok") + assert.Regexpf(t, `OK - all \d+ process\(es\) are ok.`, string(res.BuildPluginOutput()), "output ok") assert.Regexpf(t, `rss'=\d{1,15}B;;;0`, string(res.BuildPluginOutput()), "rss ok") // should work case insensitive res = snc.RunCheck("check_process", []string{"process=" + strings.ToUpper(filepath.Base(myExe))}) assert.Equalf(t, CheckExitOK, res.State, "state ok") - assert.Regexpf(t, `OK - all \d+ processes are ok.`, string(res.BuildPluginOutput()), "output ok") + assert.Regexpf(t, `OK - all \d+ process\(es\) are ok.`, string(res.BuildPluginOutput()), "output ok") assert.Regexpf(t, `rss'=\d{1,15}B;;;0`, string(res.BuildPluginOutput()), "rss ok") // check process it not running @@ -68,7 +68,7 @@ func TestCheckProcess(t *testing.T) { // appending filter to previously set filter res = snc.RunCheck("check_process", []string{"filter='pid > 0'", "filter+='pid < 10000'"}) assert.Equalf(t, CheckExitOK, res.State, "state ok") - assert.Regexpf(t, `OK - all \d+ processes are ok`, string(res.BuildPluginOutput()), "output ok") + assert.Regexpf(t, `OK - all \d+ process\(es\) are ok`, string(res.BuildPluginOutput()), "output ok") StopTestAgent(t, snc) } From 7f8c70bc67494836f2da1e212983ce4d1e6f27c6 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Wed, 29 Apr 2026 00:17:48 +0200 Subject: [PATCH 2/2] refresh docs --- docs/checks/commands/check_process.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/checks/commands/check_process.md b/docs/checks/commands/check_process.md index 639e78f9..afe7b3d6 100644 --- a/docs/checks/commands/check_process.md +++ b/docs/checks/commands/check_process.md @@ -60,15 +60,15 @@ Naemon Config ## Argument Defaults -| Argument | Default Value | -| ------------- | ------------------------------------------------ | -| warning | count = 0 | -| critical | state = 'stopped' or count = 0 | -| empty-state | 2 (CRITICAL) | -| empty-syntax | %(status) - no processes found with this filter. | -| top-syntax | %(status) - \${problem_list} | -| ok-syntax | %(status) - all %{count} processes are ok. | -| detail-syntax | \${exe}=\${state} | +| Argument | Default Value | +| ------------- | --------------------------------------------------------- | +| warning | count = 0 | +| critical | state = 'stopped' or count = 0 | +| empty-state | 2 (CRITICAL) | +| empty-syntax | %(status) - no processes found with this filter. | +| top-syntax | %(status) - %{count} process(es) running \${problem_list} | +| ok-syntax | %(status) - all %{count} process(es) are ok. | +| detail-syntax | \${exe}=\${state} | ## Check Specific Arguments