Skip to content

add additional flags to place 'count' and 'problem count' ~ 'failed' perfdata metrics to the front of metrics array.#385

Merged
sni merged 2 commits into
mainfrom
check-service-add-flags-to-prepend-count-metrics
Jun 10, 2026
Merged

add additional flags to place 'count' and 'problem count' ~ 'failed' perfdata metrics to the front of metrics array.#385
sni merged 2 commits into
mainfrom
check-service-add-flags-to-prepend-count-metrics

Conversation

@inqrphl

@inqrphl inqrphl commented May 29, 2026

Copy link
Copy Markdown
Contributor

this flag is for CheckData struct, so it can be used alongside any other check that utilizes addCountMetrics.

existing: addCountMetrics
added: addCountMetricsToFront
existing: addProblemCountMetrics
added: addProblemCountMetricsToFront

prepending is slower than appending if its a long list, so its a flag. behavior is opt-in and not default.

toggle this flag for check_service, this was the intended target for this. when each service has its own perfdata metric, which could be above 100 metrics total, the count would be appended to the end and truncated in previews.

./snclient run check_service warn="count gt 10"
WARNING - found 75 services |'count'=75;10;;0 'failed'=0;;;0 'acpid'=4 'apache2'=4 'apparmor'=3 ......

…perfdata metrics to the front of metrics array. this flag is for CheckData struct

prepending is slower than appending if its a long list, so its a flag. behavior is opt-in and not default.

toggle this flag for check_service, this was the intended target for this. when each service has its own perfdata metric, the count would be appended to the end and generally truncated in previews.
@lgmu

lgmu commented May 29, 2026

Copy link
Copy Markdown
Contributor

If we want to check the count, there is no need to print the state of each service as perf data.
Currently when using count in the critical condition, this is already correct and doesn't list the services.

The failed perf data is a nice extra, but then it should also apply for OK and CRITICAL then.

Expected Output:

OK - found 75 services | 'count'=75;100;200;0 'failed'=0;;;0
WARNING - found 75 services | 'count'=75;10;200;0 'failed'=0;;;0
CRITICAL - found 75 services | 'count'=75;10;20;0 'failed'=0;;;0

…ly in perfdata as metric

if count is not used, it adds all serices individually
@inqrphl

inqrphl commented May 29, 2026

Copy link
Copy Markdown
Contributor Author

New behavior: If "count" is used in the thresholds, stop adding each service as perfdata individually.

./snclient run check_service
OK - All 75 service(s) are ok. |'count'=75;;;0 'failed'=0;;;0 'acpid'=4 'apache2'=4 'apparmor'=3 'atd'=4 .........

./snclient run check_service warn="count gt 10"
WARNING - found 75 services |'count'=75;10;;0 'failed'=0;;;0

./snclient run check_service crit="count gt 10"
CRITICAL - found 75 services |'count'=75;;10;0 'failed'=0;;;0

./snclient run check_service warn="count gt 10000"
OK - All 75 service(s) are ok. |'count'=75;10000;;0 'failed'=0;;;0

@sni sni merged commit 1bd8f02 into main Jun 10, 2026
139 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants