From 44e4181b12553befc85ac603833c891bdedffbdc Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Wed, 29 Apr 2026 00:05:10 +0200 Subject: [PATCH 1/2] check_service: add count of service(s) to the top syntax ensures that that even when check result is warning/critical it will include the count: before: ./snclient run check_service service=cron "warning=count gt 0" WARNING - |'cron'=4 'cron rss'=1605632B;;;0 'cron vms'=18137088B;;;0 'cron cpu'=0%;;;0 'cron tasks'=1;;;0 after: ./snclient run check_service service=cron "warning= count gt 0" WARNING - 1 service(s) |'cron'=4 'cron rss'=1605632B;;;0 'cron vms'=18137088B;;;0 'cron cpu'=0%;;;0 'cron tasks'=1;;;0 --- pkg/snclient/check_service_linux.go | 2 +- pkg/snclient/check_service_windows.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/snclient/check_service_linux.go b/pkg/snclient/check_service_linux.go index 580d42d3..8cc257af 100644 --- a/pkg/snclient/check_service_linux.go +++ b/pkg/snclient/check_service_linux.go @@ -71,7 +71,7 @@ There is a specific [check_service for windows](../check_service_windows) as wel defaultFilter: "active != inactive", defaultCritical: stateCondition + " && preset != 'disabled'", detailSyntax: "${name}=${state}", - topSyntax: "%(status) - %(crit_list)", + topSyntax: "%(status) - %{count} service(s) %(crit_list)", okSyntax: "%(status) - All %(count) service(s) are ok.", emptySyntax: "%(status) - No services found", emptyState: CheckExitUnknown, diff --git a/pkg/snclient/check_service_windows.go b/pkg/snclient/check_service_windows.go index d2aa8bc3..bd063a3b 100644 --- a/pkg/snclient/check_service_windows.go +++ b/pkg/snclient/check_service_windows.go @@ -71,7 +71,7 @@ There is a specific [check_service for linux](../check_service_linux) as well.`, defaultCritical: "state != 'running' && start_type = 'auto'", defaultWarning: "state != 'running' && start_type = 'delayed'", detailSyntax: "${name}=${state} (${start_type})", - topSyntax: "%(status) - %(crit_list), delayed (%(warn_list))", + topSyntax: "%(status) - %{count} service(s) %(crit_list), delayed (%(warn_list))", okSyntax: "%(status) - All %(count) service(s) are ok.", emptySyntax: "%(status) - No services found", emptyState: CheckExitUnknown, From abf2cd325e82ae3e9c298b727192f95983023cd1 Mon Sep 17 00:00:00 2001 From: Ahmet Oeztuerk Date: Wed, 29 Apr 2026 00:17:14 +0200 Subject: [PATCH 2/2] refresh docs --- docs/checks/commands/check_service_linux.md | 2 +- docs/checks/commands/check_service_windows.md | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/checks/commands/check_service_linux.md b/docs/checks/commands/check_service_linux.md index 314454f1..1cd4cc5c 100644 --- a/docs/checks/commands/check_service_linux.md +++ b/docs/checks/commands/check_service_linux.md @@ -61,7 +61,7 @@ Naemon Config | critical | ( state not in ('running', 'oneshot', 'static') \|\| active = 'failed' ) && preset != 'disabled' | | empty-state | 3 (UNKNOWN) | | empty-syntax | %(status) - No services found | -| top-syntax | %(status) - %(crit_list) | +| top-syntax | %(status) - %{count} service(s) %(crit_list) | | ok-syntax | %(status) - All %(count) service(s) are ok. | | detail-syntax | \${name}=\${state} | diff --git a/docs/checks/commands/check_service_windows.md b/docs/checks/commands/check_service_windows.md index fa5fd1e0..26f7903f 100755 --- a/docs/checks/commands/check_service_windows.md +++ b/docs/checks/commands/check_service_windows.md @@ -50,16 +50,16 @@ Naemon Config ## Argument Defaults -| Argument | Default Value | -| ------------- | ------------------------------------------------ | -| filter | none | -| warning | state != 'running' && start_type = 'delayed' | -| critical | state != 'running' && start_type = 'auto' | -| empty-state | 3 (UNKNOWN) | -| empty-syntax | %(status) - No services found | -| top-syntax | %(status) - %(crit_list), delayed (%(warn_list)) | -| ok-syntax | %(status) - All %(count) service(s) are ok. | -| detail-syntax | \${name}=\${state} (\${start_type}) | +| Argument | Default Value | +| ------------- | -------------------------------------------------------------------- | +| filter | none | +| warning | state != 'running' && start_type = 'delayed' | +| critical | state != 'running' && start_type = 'auto' | +| empty-state | 3 (UNKNOWN) | +| empty-syntax | %(status) - No services found | +| top-syntax | %(status) - %{count} service(s) %(crit_list), delayed (%(warn_list)) | +| ok-syntax | %(status) - All %(count) service(s) are ok. | +| detail-syntax | \${name}=\${state} (\${start_type}) | ## Check Specific Arguments