From fcdcc90e866e23ce0ddd65c0ea80a8c52c2cdf2d Mon Sep 17 00:00:00 2001 From: lorenzg Date: Wed, 21 Oct 2026 13:25:21 +0200 Subject: [PATCH 1/3] replace code blocks in cmdline help page with quotes --- pkg/snclient/checkdata.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/snclient/checkdata.go b/pkg/snclient/checkdata.go index d5aab4a5..a10d8df6 100644 --- a/pkg/snclient/checkdata.go +++ b/pkg/snclient/checkdata.go @@ -1698,8 +1698,9 @@ func (cd *CheckData) helpHeader(format ShowHelp, usageHeader bool) string { if format == Markdown { out += cd.helpHeaderMarkdown(format, usageHeader) } else { + description := strings.NewReplacer("", "'", "", "'").Replace(cd.description) out += fmt.Sprintf("Usage:\n\n %s\n\n", cd.usage) - out += fmt.Sprintf(" %s\n\n", cd.description) + out += fmt.Sprintf(" %s\n\n", description) if cd.exampleDefault != "" { out += "Example:\n\n" out += fmt.Sprintf("%s\n\n", cd.exampleDefault) From 057f53fade57f41125ea46664e8f059adc777ba1 Mon Sep 17 00:00:00 2001 From: lorenzg Date: Wed, 21 Oct 2026 13:33:22 +0200 Subject: [PATCH 2/3] always use %() instead of mixing it with ${} in the syntax docs --- docs/checks/commands/check_connections.md | 20 ++--- docs/checks/commands/check_cpu.md | 6 +- docs/checks/commands/check_cpu_utilization.md | 4 +- docs/checks/commands/check_drivesize.md | 2 +- docs/checks/commands/check_eventlog.md | 2 +- docs/checks/commands/check_index.md | 4 +- docs/checks/commands/check_load.md | 16 ++-- docs/checks/commands/check_mailq.md | 4 +- docs/checks/commands/check_memory.md | 4 +- docs/checks/commands/check_mount.md | 6 +- docs/checks/commands/check_ntp_offset.md | 20 ++--- docs/checks/commands/check_omd.md | 4 +- docs/checks/commands/check_os_updates.md | 4 +- docs/checks/commands/check_os_version.md | 14 ++-- docs/checks/commands/check_pagefile.md | 20 ++--- docs/checks/commands/check_ping.md | 20 ++--- docs/checks/commands/check_process.md | 20 ++--- docs/checks/commands/check_service_linux.md | 6 +- docs/checks/commands/check_service_windows.md | 4 +- .../checks/commands/check_snclient_version.md | 14 ++-- docs/checks/commands/check_tasksched.md | 20 ++--- docs/checks/commands/check_temperature.md | 79 ------------------- docs/checks/commands/check_uptime.md | 18 ++--- docs/checks/commands/check_wmi.md | 2 +- pkg/snclient/check_connections.go | 4 +- pkg/snclient/check_cpu.go | 6 +- pkg/snclient/check_cpu_utilization.go | 4 +- pkg/snclient/check_drivesize.go | 2 +- pkg/snclient/check_eventlog.go | 2 +- pkg/snclient/check_index.go | 4 +- pkg/snclient/check_load.go | 4 +- pkg/snclient/check_mailq.go | 4 +- pkg/snclient/check_memory.go | 4 +- pkg/snclient/check_mount.go | 6 +- pkg/snclient/check_ntp_offset.go | 4 +- pkg/snclient/check_omd.go | 4 +- pkg/snclient/check_os_updates.go | 4 +- pkg/snclient/check_os_version.go | 4 +- pkg/snclient/check_pagefile.go | 4 +- pkg/snclient/check_ping.go | 4 +- pkg/snclient/check_process.go | 8 +- pkg/snclient/check_service_linux.go | 6 +- pkg/snclient/check_service_windows.go | 4 +- pkg/snclient/check_snclient_version.go | 4 +- pkg/snclient/check_tasksched.go | 4 +- pkg/snclient/check_temperature.go | 8 +- pkg/snclient/check_uptime.go | 4 +- pkg/snclient/check_wmi.go | 2 +- 48 files changed, 169 insertions(+), 248 deletions(-) diff --git a/docs/checks/commands/check_connections.md b/docs/checks/commands/check_connections.md index 9c79e7e0..e4e1befb 100644 --- a/docs/checks/commands/check_connections.md +++ b/docs/checks/commands/check_connections.md @@ -17,16 +17,16 @@ Checks the number of TCP connections. ## Argument Defaults -| Argument | Default Value | -| ------------- | -------------------------------------- | -| filter | inet=total | -| warning | total > 1000 | -| critical | total > 2000 | -| empty-state | 0 (OK) | -| empty-syntax | | -| top-syntax | %(status) - \${list} | -| ok-syntax | | -| detail-syntax | total \${prefix}connections: \${total} | +| Argument | Default Value | +| ------------- | ------------------------------------ | +| filter | inet=total | +| warning | total > 1000 | +| critical | total > 2000 | +| empty-state | 0 (OK) | +| empty-syntax | | +| top-syntax | %(status) - %(list) | +| ok-syntax | | +| detail-syntax | total %(prefix)connections: %(total) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_cpu.md b/docs/checks/commands/check_cpu.md index 0c16331b..bf9b774e 100644 --- a/docs/checks/commands/check_cpu.md +++ b/docs/checks/commands/check_cpu.md @@ -24,9 +24,9 @@ Checks the CPU usage metrics. | critical | load > 90 | | empty-state | 3 (UNKNOWN) | | empty-syntax | check_cpu failed to find anything with this filter. | -| top-syntax | %(status) - \${problem_list} on %{core_num} cores | -| ok-syntax | %(status) - CPU load is ok. %{total:fmt=%d}% on %{core_num} cores | -| detail-syntax | \${time}: \${load}% | +| top-syntax | %(status) - %(problem_list) on %(core_num) cores | +| ok-syntax | %(status) - CPU load is ok. %(total:fmt=%d)% on %(core_num) cores | +| detail-syntax | %(time): %(load)% | ## Check Specific Arguments diff --git a/docs/checks/commands/check_cpu_utilization.md b/docs/checks/commands/check_cpu_utilization.md index ef3856d5..10122c5a 100644 --- a/docs/checks/commands/check_cpu_utilization.md +++ b/docs/checks/commands/check_cpu_utilization.md @@ -23,9 +23,9 @@ Checks the CPU utilization metrics. | critical | total > 95 | | empty-state | 0 (OK) | | empty-syntax | | -| top-syntax | \${status} - \${list} | +| top-syntax | %(status) - %(list) | | ok-syntax | | -| detail-syntax | user: \${user}% - system: \${system}% - iowait: \${iowait}% - steal: \${steal}% - guest: \${guest} - idle: %{idle}% | +| detail-syntax | user: %(user)% - system: %(system)% - iowait: %(iowait)% - steal: %(steal)% - guest: %(guest) - idle: %(idle)% | ## Check Specific Arguments diff --git a/docs/checks/commands/check_drivesize.md b/docs/checks/commands/check_drivesize.md index 4718f054..dd5eb2bd 100644 --- a/docs/checks/commands/check_drivesize.md +++ b/docs/checks/commands/check_drivesize.md @@ -24,7 +24,7 @@ Checks the disk drive/volumes usage on a host. | critical | used_pct > 90 | | empty-state | 3 (UNKNOWN) | | empty-syntax | %(status) - No drives found | -| top-syntax | %(status) - \${problem_list} | +| top-syntax | %(status) - %(problem_list) | | ok-syntax | %(status) - All %(count) drive(s) are ok | | detail-syntax | %(drive_or_name) %(used)/%(size) (%(used_pct \| fmt=%.1f )%) | diff --git a/docs/checks/commands/check_eventlog.md b/docs/checks/commands/check_eventlog.md index 5e203f0a..2d19a482 100755 --- a/docs/checks/commands/check_eventlog.md +++ b/docs/checks/commands/check_eventlog.md @@ -62,7 +62,7 @@ the filter is still applied to the returned events. | timezone | Sets the timezone for time metrics (default is local time) | | truncate-message | Maximum length of message for each event log message text | | unique | Alias for unique-index | -| unique-index | Combination of fields that identifies unique events, set to 0 to disable. Default is "\${log}-\${source}-\${id}" | +| unique-index | Combination of fields that identifies unique events, set to 0 to disable. Default is "%(log)-%(source)-%(id)" | ## Attributes diff --git a/docs/checks/commands/check_index.md b/docs/checks/commands/check_index.md index 1ba355f1..18b90994 100644 --- a/docs/checks/commands/check_index.md +++ b/docs/checks/commands/check_index.md @@ -22,9 +22,9 @@ Returns list of all known checks. | filter | implemented = 1 | | empty-state | 3 (UNKNOWN) | | empty-syntax | no checks found | -| top-syntax | \${list} | +| top-syntax | %(list) | | ok-syntax | | -| detail-syntax | \${name} | +| detail-syntax | %(name) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_load.md b/docs/checks/commands/check_load.md index 497a6880..7e37cd28 100644 --- a/docs/checks/commands/check_load.md +++ b/docs/checks/commands/check_load.md @@ -17,14 +17,14 @@ Checks the CPU load metrics. ## Argument Defaults -| Argument | Default Value | -| ------------- | ------------------------------------------------------- | -| filter | none | -| empty-state | 0 (OK) | -| empty-syntax | | -| top-syntax | %(status) - \${list} on \${cores} cores | -| ok-syntax | | -| detail-syntax | \${type} load average: \${load1}, \${load5}, \${load15} | +| Argument | Default Value | +| ------------- | --------------------------------------------------- | +| filter | none | +| empty-state | 0 (OK) | +| empty-syntax | | +| top-syntax | %(status) - %(list) on %(cores) cores | +| ok-syntax | | +| detail-syntax | %(type) load average: %(load1), %(load5), %(load15) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_mailq.md b/docs/checks/commands/check_mailq.md index 67b8fe58..08bd69e0 100644 --- a/docs/checks/commands/check_mailq.md +++ b/docs/checks/commands/check_mailq.md @@ -24,9 +24,9 @@ Checks the mailq. | critical | active > 10 \|\| active_size > 20MB \|\| deferred > 10 \|\| deferred_size > 20MB | | empty-state | 3 (UNKNOWN) | | empty-syntax | %(status) - could not get any mailq data | -| top-syntax | %(status) - \${list} | +| top-syntax | %(status) - %(list) | | ok-syntax | | -| detail-syntax | \${mta}: active \${active} / deferred \${deferred} | +| detail-syntax | %(mta): active %(active) / deferred %(deferred) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_memory.md b/docs/checks/commands/check_memory.md index f5c6073f..4960f940 100644 --- a/docs/checks/commands/check_memory.md +++ b/docs/checks/commands/check_memory.md @@ -32,7 +32,7 @@ Read more on Windows virtual address space [here](https://learn.microsoft.com/en | critical | used > 90% | | empty-state | 0 (OK) | | empty-syntax | | -| top-syntax | %(status) - \${list} | +| top-syntax | %(status) - %(list) | | ok-syntax | | | detail-syntax | %(type) = %(used)/%(size) (%(used_pct \| fmt=%.1f )%) | @@ -72,7 +72,7 @@ these can be used in filters and thresholds (along with the default attributes): Changing the return syntax to get more information: - check_memory 'top-syntax=${list}' 'detail-syntax=${type} free: ${free} used: ${used} size: ${size}' + check_memory 'top-syntax=%(list)' 'detail-syntax=%(type) free: %(free) used: %(used) size: %(size)' physical free: 35.00 B used: 7.01 GiB size: 31.09 GiB, committed free: 27.00 B used: 705.57 MiB size: 977.00 MiB |... ### Example using check_snclient and Naemon diff --git a/docs/checks/commands/check_mount.md b/docs/checks/commands/check_mount.md index 9905f8a9..ff88469a 100644 --- a/docs/checks/commands/check_mount.md +++ b/docs/checks/commands/check_mount.md @@ -23,9 +23,9 @@ Checks the status for a mounted filesystem | critical | issues like 'not mounted' | | empty-state | 3 (UNKNOWN) | | empty-syntax | check_mount failed to find anything with this filter. | -| top-syntax | \${status} - \${problem_list} | -| ok-syntax | \${status} - \${count} mount(s) found | -| detail-syntax | mount \${mount} \${issues} | +| top-syntax | %(status) - %(problem_list) | +| ok-syntax | %(status) - %(count) mount(s) found | +| detail-syntax | mount %(mount) %(issues) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_ntp_offset.md b/docs/checks/commands/check_ntp_offset.md index e272ef7e..4a1933bf 100644 --- a/docs/checks/commands/check_ntp_offset.md +++ b/docs/checks/commands/check_ntp_offset.md @@ -17,16 +17,16 @@ Checks the NTP offset. ## Argument Defaults -| Argument | Default Value | -| ------------- | -------------------------------------------------- | -| filter | none | -| warning | offset > 50 \|\| offset < -50 | -| critical | offset > 100 \|\| offset < -100 | -| empty-state | 3 (UNKNOWN) | -| empty-syntax | %(status) - could not get any ntp data | -| top-syntax | %(status) - \${list} | -| ok-syntax | | -| detail-syntax | offset \${offset_seconds:duration} from \${server} | +| Argument | Default Value | +| ------------- | ------------------------------------------------ | +| filter | none | +| warning | offset > 50 \|\| offset < -50 | +| critical | offset > 100 \|\| offset < -100 | +| empty-state | 3 (UNKNOWN) | +| empty-syntax | %(status) - could not get any ntp data | +| top-syntax | %(status) - %(list) | +| ok-syntax | | +| detail-syntax | offset %(offset_seconds:duration) from %(server) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_omd.md b/docs/checks/commands/check_omd.md index 07ef4e43..950ba3b4 100644 --- a/docs/checks/commands/check_omd.md +++ b/docs/checks/commands/check_omd.md @@ -24,9 +24,9 @@ Check OMD site status. | critical | state >= 2 | | empty-state | 3 (UNKNOWN) | | empty-syntax | check_omd failed to find any site with this filter. | -| top-syntax | \${status} - \${list} | +| top-syntax | %(status) - %(list) | | ok-syntax | | -| detail-syntax | site \${site}: \${status}\${failed_services_txt} | +| detail-syntax | site %(site): %(status)%(failed_services_txt) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_os_updates.md b/docs/checks/commands/check_os_updates.md index 390c54eb..82117dd1 100644 --- a/docs/checks/commands/check_os_updates.md +++ b/docs/checks/commands/check_os_updates.md @@ -23,9 +23,9 @@ Checks for OS system updates. | critical | count_security > 0 | | empty-state | 0 (OK) | | empty-syntax | %(status) - no updates available | -| top-syntax | %(status) - %{count_security} security updates / %{count} updates available.\n%{list} | +| top-syntax | %(status) - %(count_security) security updates / %(count) updates available.\n%(list) | | ok-syntax | | -| detail-syntax | \${prefix}\${package}: \${version} | +| detail-syntax | %(prefix)%(package): %(version) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_os_version.md b/docs/checks/commands/check_os_version.md index 2df24eab..ad0d656f 100644 --- a/docs/checks/commands/check_os_version.md +++ b/docs/checks/commands/check_os_version.md @@ -17,13 +17,13 @@ Checks the os system version. ## Argument Defaults -| Argument | Default Value | -| ------------- | ----------------------------------------- | -| empty-state | 0 (OK) | -| empty-syntax | | -| top-syntax | %(status) - \${list} | -| ok-syntax | | -| detail-syntax | \${platform} \${version} (arch: \${arch}) | +| Argument | Default Value | +| ------------- | -------------------------------------- | +| empty-state | 0 (OK) | +| empty-syntax | | +| top-syntax | %(status) - %(list) | +| ok-syntax | | +| detail-syntax | %(platform) %(version) (arch: %(arch)) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_pagefile.md b/docs/checks/commands/check_pagefile.md index a87369d0..5f00a978 100644 --- a/docs/checks/commands/check_pagefile.md +++ b/docs/checks/commands/check_pagefile.md @@ -17,16 +17,16 @@ Checks the pagefile usage. ## Argument Defaults -| Argument | Default Value | -| ------------- | ------------------------------------------------------ | -| filter | name = 'total' | -| warning | used > 60% | -| critical | used > 80% | -| empty-state | 0 (OK) | -| empty-syntax | | -| top-syntax | %(status) - \${list} | -| ok-syntax | | -| detail-syntax | \${name} \${used}/\${size} (%(used_pct \| fmt=%.1f )%) | +| Argument | Default Value | +| ------------- | --------------------------------------------------- | +| filter | name = 'total' | +| warning | used > 60% | +| critical | used > 80% | +| empty-state | 0 (OK) | +| empty-syntax | | +| top-syntax | %(status) - %(list) | +| ok-syntax | | +| detail-syntax | %(name) %(used)/%(size) (%(used_pct \| fmt=%.1f )%) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_ping.md b/docs/checks/commands/check_ping.md index 650d87bb..4b7ca7d7 100644 --- a/docs/checks/commands/check_ping.md +++ b/docs/checks/commands/check_ping.md @@ -17,16 +17,16 @@ Checks the ICMP ping connection. ## Argument Defaults -| Argument | Default Value | -| ------------- | ----------------------------------------------------------------- | -| filter | none | -| warning | rta > 1000 \|\| pl > 30 | -| critical | rta > 5000 \|\| pl > 80 | -| empty-state | 3 (UNKNOWN) | -| empty-syntax | %(status) - could not get any ping data | -| top-syntax | %(status) - \${list} | -| ok-syntax | | -| detail-syntax | Packet loss = \${pl}%{{ IF rta != '' }}, RTA = \${rta}ms{{ END }} | +| Argument | Default Value | +| ------------- | --------------------------------------------------------------- | +| filter | none | +| warning | rta > 1000 \|\| pl > 30 | +| critical | rta > 5000 \|\| pl > 80 | +| empty-state | 3 (UNKNOWN) | +| empty-syntax | %(status) - could not get any ping data | +| top-syntax | %(status) - %(list) | +| ok-syntax | | +| detail-syntax | Packet loss = %(pl)%{{ IF rta != '' }}, RTA = %(rta)ms{{ END }} | ## Check Specific Arguments diff --git a/docs/checks/commands/check_process.md b/docs/checks/commands/check_process.md index 635b34ff..644b597a 100644 --- a/docs/checks/commands/check_process.md +++ b/docs/checks/commands/check_process.md @@ -17,15 +17,15 @@ Checks the state and metrics of one or multiple processes. ## 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 \|\| 'found \${count} processes'} | -| 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) - %(problem_list \|\| 'found %(count) processes') | +| ok-syntax | %(status) - all %(count) processes are ok. | +| detail-syntax | %(exe)=%(state) | ## Check Specific Arguments @@ -79,7 +79,7 @@ Check specific process(es) by name (adding some metrics as well) process=httpd \ warn='count < 1 || count > 10' \ crit='count < 0 || count > 20' \ - top-syntax='%{status} - %{count} processes, memory %{rss|h}B, cpu %{cpu:fmt=%.1f}%, started %{oldest:age|duration} ago' + top-syntax='%(status) - %(count) processes, memory %(rss|h)B, cpu %(cpu:fmt=%.1f)%, started %(oldest:age|duration) ago' WARNING - 12 processes, memory 62.58 MB, cpu 0.7%, started 01:11h ago |... If zero is a valid threshold, set thresholds accordingly diff --git a/docs/checks/commands/check_service_linux.md b/docs/checks/commands/check_service_linux.md index 08575807..ce37ab4d 100644 --- a/docs/checks/commands/check_service_linux.md +++ b/docs/checks/commands/check_service_linux.md @@ -25,9 +25,9 @@ There is a specific [check_service for Windows](../check_service_windows) as wel | 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 \|\| 'found \${count} services') | +| top-syntax | %(status) - %(crit_list \|\| 'found %(count) services') | | ok-syntax | %(status) - All %(count) service(s) are ok. | -| detail-syntax | \${name}=\${state} | +| detail-syntax | %(name)=%(state) | ## Check Specific Arguments @@ -69,7 +69,7 @@ Checking all services except some excluded ones: Or check a specific service and get some metrics: - check_service service=docker ok-syntax='${top-syntax}' top-syntax='%(status) - %(list)' detail-syntax='%(name) %(state) - memory: %(rss:h)B - age: %(age:duration)' + check_service service=docker ok-syntax='%(top-syntax)' top-syntax='%(status) - %(list)' detail-syntax='%(name) %(state) - memory: %(rss:h)B - age: %(age:duration)' OK - docker running - memory: 805.2MB - age: 01:11h |'docker'=4 'docker rss'=805200000B Check memory usage of specific service: diff --git a/docs/checks/commands/check_service_windows.md b/docs/checks/commands/check_service_windows.md index 26f2a5c0..31f1732e 100755 --- a/docs/checks/commands/check_service_windows.md +++ b/docs/checks/commands/check_service_windows.md @@ -26,9 +26,9 @@ There is a specific [check_service for Linux](../check_service_linux) as well. | critical | state != 'running' && start_type = 'auto' | | empty-state | 3 (UNKNOWN) | | empty-syntax | %(status) - No services found | -| top-syntax | %(status) - %(crit_list){{ IF crit_list != '' and warn_list != '' }}, {{ END }}{{ IF warn_list != '' }}delayed (%(warn_list)){{ END }}{{ IF crit_list == '' and warn_list == '' }}found \${count} services{{ END }} | +| top-syntax | %(status) - %(crit_list){{ IF crit_list != '' and warn_list != '' }}, {{ END }}{{ IF warn_list != '' }}delayed (%(warn_list)){{ END }}{{ IF crit_list == '' and warn_list == '' }}found %(count) services{{ END }} | | ok-syntax | %(status) - All %(count) service(s) are ok. | -| detail-syntax | \${name}=\${state} (\${start_type}) | +| detail-syntax | %(name)=%(state) (%(start_type)) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_snclient_version.md b/docs/checks/commands/check_snclient_version.md index e9927e8d..410dc207 100644 --- a/docs/checks/commands/check_snclient_version.md +++ b/docs/checks/commands/check_snclient_version.md @@ -17,13 +17,13 @@ Check and return SNClient version. ## Argument Defaults -| Argument | Default Value | -| ------------- | ----------------------------------------------- | -| empty-state | 0 (OK) | -| empty-syntax | | -| top-syntax | \${list} | -| ok-syntax | | -| detail-syntax | \${name} \${version} (Build: \${build}, \${go}) | +| Argument | Default Value | +| ------------- | ------------------------------------------- | +| empty-state | 0 (OK) | +| empty-syntax | | +| top-syntax | %(list) | +| ok-syntax | | +| detail-syntax | %(name) %(version) (Build: %(build), %(go)) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_tasksched.md b/docs/checks/commands/check_tasksched.md index 0c64a7eb..ee0d8e4f 100644 --- a/docs/checks/commands/check_tasksched.md +++ b/docs/checks/commands/check_tasksched.md @@ -17,16 +17,16 @@ Check status of scheduled jobs ## Argument Defaults -| Argument | Default Value | -| ------------- | ---------------------------------------------------------------------- | -| filter | enabled = true | -| warning | exit_code != 0 | -| critical | exit_code < 0 | -| empty-state | 3 (UNKNOWN) | -| empty-syntax | %(status) - No tasks found | -| top-syntax | %(status) - \${problem_list} | -| ok-syntax | %(status) - All tasks are ok | -| detail-syntax | \${uri_clean} (%{most_recent_run_time:date}) exited with \${exit_code} | +| Argument | Default Value | +| ------------- | -------------------------------------------------------------------- | +| filter | enabled = true | +| warning | exit_code != 0 | +| critical | exit_code < 0 | +| empty-state | 3 (UNKNOWN) | +| empty-syntax | %(status) - No tasks found | +| top-syntax | %(status) - %(problem_list) | +| ok-syntax | %(status) - All tasks are ok | +| detail-syntax | %(uri_clean) (%(most_recent_run_time:date)) exited with %(exit_code) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_temperature.md b/docs/checks/commands/check_temperature.md index dec075ed..e69de29b 100644 --- a/docs/checks/commands/check_temperature.md +++ b/docs/checks/commands/check_temperature.md @@ -1,79 +0,0 @@ ---- -title: check_temperature -comment: auto-generated by make docs, do not edit ---- - -Check temperature sensors. - -- [Argument Defaults](#argument-defaults) -- [Attributes](#attributes) -- [Examples](#examples) - -## Implementation - -| Windows | Linux | FreeBSD | MacOSX | -|:------------------:|:------------------:|:-------:|:------------------:| -| :white_check_mark: | :white_check_mark: | | :white_check_mark: | - -## Argument Defaults - -| Argument | Default Value | -| ------------- | ------------------------------------------------------------------------------ | -| filter | temperature != 0 and temperature != 1 | -| warning | (min != 0 && temperature < \${min}) \|\| (crit != 0 && temperature > \${crit}) | -| critical | (min != 0 && temperature < \${min}) \|\| (crit != 0 && temperature > \${crit}) | -| empty-state | 3 (UNKNOWN) | -| empty-syntax | check_temperature failed to find any sensors. | -| top-syntax | \${status} - \${list} | -| ok-syntax | | -| detail-syntax | \${sensor}: \${temperature:fmt=%.1f} °C | - -## Check Specific Arguments - -| Argument | Description | -| -------- | --------------------- | -| sensor | Show this sensor only | - -## Attributes - -### Filter Keywords - -these can be used in filters and thresholds (along with the default attributes): - -| Attribute | Description | -| ----------- | ---------------------------------------------- | -| sensor | full name of this sensor, e.g. coretemp_core_0 | -| name | name of this sensor, e.g. coretemp | -| label | label for this sensor, e.g. core 0 | -| temperature | current temperature | -| crit | critical value supplied from sensor | -| max | max value supplied from sensor | -| min | min value supplied from sensor | - -## Examples - -### Default Check - - check_temperature - OK - Package id 0: 65.0 °C, Core 0: 62.0 °C, Core 1: 61.0 °C, Core 2: 65.0 °C |... - -Show all temperature sensors and apply custom thresholds: - - check_temperature filter=none warn="temperature > 85" crit="temperature > 90" - OK - Package id 0: 65.0 °C, Core 0: 62.0 °C, Core 1: 61.0 °C, Core 2: 65.0 °C |... - -### Example using check_snclient and Naemon - -Naemon Config - - define command{ - command_name check_snclient - command_line $USER1$/check_snclient -k -p 'your-password' -u 'https://$HOSTADDRESS$:8443' $ARG1$ $ARG2$ - } - - define service { - host_name testhost - service_description check_temperature - use generic-service - check_command check_snclient!check_temperature! - } diff --git a/docs/checks/commands/check_uptime.md b/docs/checks/commands/check_uptime.md index 0edf1034..597d9476 100644 --- a/docs/checks/commands/check_uptime.md +++ b/docs/checks/commands/check_uptime.md @@ -17,15 +17,15 @@ Check computer uptime (time since last reboot). ## Argument Defaults -| Argument | Default Value | -| ------------- | ----------------------------------------- | -| warning | uptime < 2d | -| critical | uptime < 1d | -| empty-state | 0 (OK) | -| empty-syntax | | -| top-syntax | %(status) - \${list} | -| ok-syntax | | -| detail-syntax | uptime: \${uptime}, boot: \${boot \| utc} | +| Argument | Default Value | +| ------------- | --------------------------------------- | +| warning | uptime < 2d | +| critical | uptime < 1d | +| empty-state | 0 (OK) | +| empty-syntax | | +| top-syntax | %(status) - %(list) | +| ok-syntax | | +| detail-syntax | uptime: %(uptime), boot: %(boot \| utc) | ## Check Specific Arguments diff --git a/docs/checks/commands/check_wmi.md b/docs/checks/commands/check_wmi.md index 205693b3..633481c8 100644 --- a/docs/checks/commands/check_wmi.md +++ b/docs/checks/commands/check_wmi.md @@ -22,7 +22,7 @@ In order to use this plugin, you need to enable CheckWMI in the 1000", defaultCritical: "total > 2000", - detailSyntax: "total ${prefix}connections: ${total}", - topSyntax: "%(status) - ${list}", + detailSyntax: "total %(prefix)connections: %(total)", + topSyntax: "%(status) - %(list)", attributes: []CheckAttribute{ {name: "inet", description: "address family, can be total (sum of any), all (any+total), any (v4+v6), inet4 or inet6"}, {name: "prefix", description: "address family as prefix, will be empty, inet4 or inet6"}, diff --git a/pkg/snclient/check_cpu.go b/pkg/snclient/check_cpu.go index 7abf22e5..f626f4e5 100644 --- a/pkg/snclient/check_cpu.go +++ b/pkg/snclient/check_cpu.go @@ -44,9 +44,9 @@ func (l *CheckCPU) Build() *CheckData { defaultFilter: "core = 'total'", defaultWarning: "load > 80", defaultCritical: "load > 90", - okSyntax: "%(status) - CPU load is ok. %{total:fmt=%d}% on %{core_num} cores", - detailSyntax: "${time}: ${load}%", - topSyntax: "%(status) - ${problem_list} on %{core_num} cores", + okSyntax: "%(status) - CPU load is ok. %(total:fmt=%d)% on %(core_num) cores", + detailSyntax: "%(time): %(load)%", + topSyntax: "%(status) - %(problem_list) on %(core_num) cores", emptyState: 3, emptySyntax: "check_cpu failed to find anything with this filter.", attributes: []CheckAttribute{ diff --git a/pkg/snclient/check_cpu_utilization.go b/pkg/snclient/check_cpu_utilization.go index 194cf5f5..ab2156f2 100644 --- a/pkg/snclient/check_cpu_utilization.go +++ b/pkg/snclient/check_cpu_utilization.go @@ -55,8 +55,8 @@ func (l *CheckCPUUtilization) Build() *CheckData { }, defaultWarning: "total > 90", defaultCritical: "total > 95", - topSyntax: "${status} - ${list}", - detailSyntax: "user: ${user}% - system: ${system}% - iowait: ${iowait}% - steal: ${steal}% - guest: ${guest} - idle: %{idle}%", + topSyntax: "%(status) - %(list)", + detailSyntax: "user: %(user)% - system: %(system)% - iowait: %(iowait)% - steal: %(steal)% - guest: %(guest) - idle: %(idle)%", attributes: []CheckAttribute{ {name: "total", description: "Sum of user, system, iowait, steal and guest in percent", unit: UPercent}, {name: "user", description: "User CPU utilization in percent", unit: UPercent}, diff --git a/pkg/snclient/check_drivesize.go b/pkg/snclient/check_drivesize.go index ecb63830..a4adde32 100644 --- a/pkg/snclient/check_drivesize.go +++ b/pkg/snclient/check_drivesize.go @@ -106,7 +106,7 @@ func (l *CheckDrivesize) Build() *CheckData { defaultCritical: "used_pct > 90", okSyntax: "%(status) - All %(count) drive(s) are ok", detailSyntax: "%(drive_or_name) %(used)/%(size) (%(used_pct | fmt=%.1f )%)", - topSyntax: "%(status) - ${problem_list}", + topSyntax: "%(status) - %(problem_list)", emptyState: CheckExitUnknown, emptySyntax: "%(status) - No drives found", attributes: []CheckAttribute{ diff --git a/pkg/snclient/check_eventlog.go b/pkg/snclient/check_eventlog.go index 2c3b38b6..3177e891 100644 --- a/pkg/snclient/check_eventlog.go +++ b/pkg/snclient/check_eventlog.go @@ -4,7 +4,7 @@ func init() { AvailableChecks["check_eventlog"] = CheckEntry{"check_eventlog", NewCheckEventlog} } -const DefaultUniqueIndex = "${log}-${source}-${id}" +const DefaultUniqueIndex = "%(log)-%(source)-%(id)" type CheckEventlog struct { files []string diff --git a/pkg/snclient/check_index.go b/pkg/snclient/check_index.go index a216f5fd..2799976f 100644 --- a/pkg/snclient/check_index.go +++ b/pkg/snclient/check_index.go @@ -23,8 +23,8 @@ func (l *CheckIndex) Build() *CheckData { name: "check_index", description: "Returns list of all known checks.", implemented: ALL, - detailSyntax: "${name}", - topSyntax: "${list}", + detailSyntax: "%(name)", + topSyntax: "%(list)", listCombine: "\n", defaultFilter: "implemented = 1", emptyState: 3, diff --git a/pkg/snclient/check_load.go b/pkg/snclient/check_load.go index 32db2d04..f2ec0938 100644 --- a/pkg/snclient/check_load.go +++ b/pkg/snclient/check_load.go @@ -54,8 +54,8 @@ func (l *CheckLoad) Build() *CheckData { "--show-args": {value: &l.showArgs, description: "Show arguments when listing the top N processes"}, }, defaultFilter: "none", - detailSyntax: "${type} load average: ${load1}, ${load5}, ${load15}", - topSyntax: "%(status) - ${list} on ${cores} cores", + detailSyntax: "%(type) load average: %(load1), %(load5), %(load15)", + topSyntax: "%(status) - %(list) on %(cores) cores", listCombine: " - ", attributes: []CheckAttribute{ {name: "type", description: "type will be either 'total' or 'scaled'"}, diff --git a/pkg/snclient/check_mailq.go b/pkg/snclient/check_mailq.go index de45beec..a4561234 100644 --- a/pkg/snclient/check_mailq.go +++ b/pkg/snclient/check_mailq.go @@ -44,8 +44,8 @@ func (l *CheckMailq) Build() *CheckData { defaultFilter: "none", defaultWarning: "active > 5 || active_size > 10MB || deferred > 0 || deferred_size > 10MB", defaultCritical: "active > 10 || active_size > 20MB || deferred > 10 || deferred_size > 20MB", - detailSyntax: "${mta}: active ${active} / deferred ${deferred}", - topSyntax: "%(status) - ${list}", + detailSyntax: "%(mta): active %(active) / deferred %(deferred)", + topSyntax: "%(status) - %(list)", emptyState: CheckExitUnknown, emptySyntax: "%(status) - could not get any mailq data", attributes: []CheckAttribute{ diff --git a/pkg/snclient/check_memory.go b/pkg/snclient/check_memory.go index 49054dad..0c50e3aa 100644 --- a/pkg/snclient/check_memory.go +++ b/pkg/snclient/check_memory.go @@ -62,7 +62,7 @@ Read more on Windows virtual address space [here](https://learn.microsoft.com/en defaultWarning: "used > 80%", defaultCritical: "used > 90%", detailSyntax: "%(type) = %(used)/%(size) (%(used_pct | fmt=%.1f )%)", - topSyntax: "%(status) - ${list}", + topSyntax: "%(status) - %(list)", attributes: []CheckAttribute{ {name: "", description: "used bytes with the type as key", unit: UByte}, {name: "type", description: "checked type, either 'physical' or 'committed', 'swap' or 'virtual' (Windows only)"}, @@ -87,7 +87,7 @@ Read more on Windows virtual address space [here](https://learn.microsoft.com/en Changing the return syntax to get more information: - check_memory 'top-syntax=${list}' 'detail-syntax=${type} free: ${free} used: ${used} size: ${size}' + check_memory 'top-syntax=%(list)' 'detail-syntax=%(type) free: %(free) used: %(used) size: %(size)' physical free: 35.00 B used: 7.01 GiB size: 31.09 GiB, committed free: 27.00 B used: 705.57 MiB size: 977.00 MiB |... `, exampleArgs: `'warn=used > 80%' 'crit=used > 90%'`, diff --git a/pkg/snclient/check_mount.go b/pkg/snclient/check_mount.go index ba2f6872..0c387cf5 100644 --- a/pkg/snclient/check_mount.go +++ b/pkg/snclient/check_mount.go @@ -39,9 +39,9 @@ func (l *CheckMount) Build() *CheckData { "options": {value: &l.expectOptions, description: "The mount options to expect"}, "fstype": {value: &l.expectFSType, description: "The fstype to expect"}, }, - detailSyntax: "mount ${mount} ${issues}", - okSyntax: "${status} - ${count} mount(s) found", - topSyntax: "${status} - ${problem_list}", + detailSyntax: "mount %(mount) %(issues)", + okSyntax: "%(status) - %(count) mount(s) found", + topSyntax: "%(status) - %(problem_list)", defaultWarning: "issues != ''", defaultCritical: "issues like 'not mounted'", emptyState: 3, diff --git a/pkg/snclient/check_ntp_offset.go b/pkg/snclient/check_ntp_offset.go index 02f3d7d9..c91699da 100644 --- a/pkg/snclient/check_ntp_offset.go +++ b/pkg/snclient/check_ntp_offset.go @@ -48,8 +48,8 @@ func (l *CheckNTPOffset) Build() *CheckData { defaultFilter: "none", defaultWarning: "offset > 50 || offset < -50", defaultCritical: "offset > 100 || offset < -100", - detailSyntax: "offset ${offset_seconds:duration} from ${server}", - topSyntax: "%(status) - ${list}", + detailSyntax: "offset %(offset_seconds:duration) from %(server)", + topSyntax: "%(status) - %(list)", emptyState: CheckExitUnknown, emptySyntax: "%(status) - could not get any ntp data", attributes: []CheckAttribute{ diff --git a/pkg/snclient/check_omd.go b/pkg/snclient/check_omd.go index 793c15f3..f1650bbc 100644 --- a/pkg/snclient/check_omd.go +++ b/pkg/snclient/check_omd.go @@ -48,8 +48,8 @@ func (l *CheckOMD) Build() *CheckData { defaultWarning: "state == 1", defaultCritical: "state >= 2", defaultFilter: "autostart = 1", - topSyntax: "${status} - ${list}", - detailSyntax: "site ${site}: ${status}${failed_services_txt}", + topSyntax: "%(status) - %(list)", + detailSyntax: "site %(site): %(status)%(failed_services_txt)", emptyState: 3, emptySyntax: "check_omd failed to find any site with this filter.", attributes: []CheckAttribute{ diff --git a/pkg/snclient/check_os_updates.go b/pkg/snclient/check_os_updates.go index 0daa4c09..40a8bc2d 100644 --- a/pkg/snclient/check_os_updates.go +++ b/pkg/snclient/check_os_updates.go @@ -46,9 +46,9 @@ func (l *CheckOSUpdates) Build() *CheckData { }, defaultWarning: "count > 0", defaultCritical: "count_security > 0", - detailSyntax: "${prefix}${package}: ${version}", + detailSyntax: "%(prefix)%(package): %(version)", listCombine: "\n", - topSyntax: "%(status) - %{count_security} security updates / %{count} updates available.\n%{list}", + topSyntax: "%(status) - %(count_security) security updates / %(count) updates available.\n%(list)", emptyState: CheckExitOK, emptySyntax: "%(status) - no updates available", attributes: []CheckAttribute{ diff --git a/pkg/snclient/check_os_version.go b/pkg/snclient/check_os_version.go index fa755f8d..66599947 100644 --- a/pkg/snclient/check_os_version.go +++ b/pkg/snclient/check_os_version.go @@ -28,8 +28,8 @@ func (l *CheckOSVersion) Build() *CheckData { result: &CheckResult{ State: CheckExitOK, }, - topSyntax: "%(status) - ${list}", - detailSyntax: "${platform} ${version} (arch: ${arch})", + topSyntax: "%(status) - %(list)", + detailSyntax: "%(platform) %(version) (arch: %(arch))", attributes: []CheckAttribute{ {name: "platform", description: "Platform of the OS"}, {name: "family", description: "OS Family"}, diff --git a/pkg/snclient/check_pagefile.go b/pkg/snclient/check_pagefile.go index 7f1bbb37..0f951220 100644 --- a/pkg/snclient/check_pagefile.go +++ b/pkg/snclient/check_pagefile.go @@ -28,8 +28,8 @@ func (l *CheckPagefile) Build() *CheckData { defaultFilter: "name = 'total'", defaultWarning: "used > 60%", defaultCritical: "used > 80%", - detailSyntax: "${name} ${used}/${size} (%(used_pct | fmt=%.1f )%)", - topSyntax: "%(status) - ${list}", + detailSyntax: "%(name) %(used)/%(size) (%(used_pct | fmt=%.1f )%)", + topSyntax: "%(status) - %(list)", attributes: []CheckAttribute{ {name: "name", description: "The name of the page file (location)"}, {name: "used", description: "Used memory in human readable bytes", unit: UByte}, diff --git a/pkg/snclient/check_ping.go b/pkg/snclient/check_ping.go index fd864fa7..27ae9cab 100644 --- a/pkg/snclient/check_ping.go +++ b/pkg/snclient/check_ping.go @@ -49,8 +49,8 @@ func (l *CheckPing) Build() *CheckData { defaultFilter: "none", defaultWarning: "rta > 1000 || pl > 30", defaultCritical: "rta > 5000 || pl > 80", - detailSyntax: "Packet loss = ${pl}%{{ IF rta != '' }}, RTA = ${rta}ms{{ END }}", - topSyntax: "%(status) - ${list}", + detailSyntax: "Packet loss = %(pl)%{{ IF rta != '' }}, RTA = %(rta)ms{{ END }}", + topSyntax: "%(status) - %(list)", emptyState: CheckExitUnknown, emptySyntax: "%(status) - could not get any ping data", attributes: []CheckAttribute{ diff --git a/pkg/snclient/check_process.go b/pkg/snclient/check_process.go index 08e43882..9a9c74d3 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.", - detailSyntax: "${exe}=${state}", - topSyntax: "%(status) - ${problem_list || 'found ${count} processes'}", + okSyntax: "%(status) - all %(count) processes are ok.", + detailSyntax: "%(exe)=%(state)", + topSyntax: "%(status) - %(problem_list || 'found %(count) processes')", emptyState: 2, emptySyntax: "%(status) - no processes found with this filter.", defaultWarning: "count = 0", @@ -77,7 +77,7 @@ Check specific process(es) by name (adding some metrics as well) process=httpd \ warn='count < 1 || count > 10' \ crit='count < 0 || count > 20' \ - top-syntax='%{status} - %{count} processes, memory %{rss|h}B, cpu %{cpu:fmt=%.1f}%, started %{oldest:age|duration} ago' + top-syntax='%(status) - %(count) processes, memory %(rss|h)B, cpu %(cpu:fmt=%.1f)%, started %(oldest:age|duration) ago' WARNING - 12 processes, memory 62.58 MB, cpu 0.7%, started 01:11h ago |... If zero is a valid threshold, set thresholds accordingly diff --git a/pkg/snclient/check_service_linux.go b/pkg/snclient/check_service_linux.go index 676cc13d..1f243b90 100644 --- a/pkg/snclient/check_service_linux.go +++ b/pkg/snclient/check_service_linux.go @@ -70,8 +70,8 @@ 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 || 'found ${count} services')", + detailSyntax: "%(name)=%(state)", + topSyntax: "%(status) - %(crit_list || 'found %(count) services')", okSyntax: "%(status) - All %(count) service(s) are ok.", emptySyntax: "%(status) - No services found", emptyState: CheckExitUnknown, @@ -98,7 +98,7 @@ Checking all services except some excluded ones: Or check a specific service and get some metrics: - check_service service=docker ok-syntax='${top-syntax}' top-syntax='%(status) - %(list)' detail-syntax='%(name) %(state) - memory: %(rss:h)B - age: %(age:duration)' + check_service service=docker ok-syntax='%(top-syntax)' top-syntax='%(status) - %(list)' detail-syntax='%(name) %(state) - memory: %(rss:h)B - age: %(age:duration)' OK - docker running - memory: 805.2MB - age: 01:11h |'docker'=4 'docker rss'=805200000B Check memory usage of specific service: diff --git a/pkg/snclient/check_service_windows.go b/pkg/snclient/check_service_windows.go index e25c88c9..8828192d 100644 --- a/pkg/snclient/check_service_windows.go +++ b/pkg/snclient/check_service_windows.go @@ -70,11 +70,11 @@ There is a specific [check_service for Linux](../check_service_linux) as well.`, defaultFilter: "none", defaultCritical: "state != 'running' && start_type = 'auto'", defaultWarning: "state != 'running' && start_type = 'delayed'", - detailSyntax: "${name}=${state} (${start_type})", + detailSyntax: "%(name)=%(state) (%(start_type))", topSyntax: `%(status) - ` + `%(crit_list){{ IF crit_list != '' and warn_list != '' }}, {{ END }}` + `{{ IF warn_list != '' }}delayed (%(warn_list)){{ END }}` + - `{{ IF crit_list == '' and warn_list == '' }}found ${count} services{{ END }}`, + `{{ IF crit_list == '' and warn_list == '' }}found %(count) services{{ END }}`, okSyntax: "%(status) - All %(count) service(s) are ok.", emptySyntax: "%(status) - No services found", emptyState: CheckExitUnknown, diff --git a/pkg/snclient/check_snclient_version.go b/pkg/snclient/check_snclient_version.go index 2b5481f0..a3c99b0b 100644 --- a/pkg/snclient/check_snclient_version.go +++ b/pkg/snclient/check_snclient_version.go @@ -26,8 +26,8 @@ func (l *CheckSNClientVersion) Build() *CheckData { result: &CheckResult{ State: CheckExitOK, }, - detailSyntax: "${name} ${version} (Build: ${build}, ${go})", - topSyntax: "${list}", + detailSyntax: "%(name) %(version) (Build: %(build), %(go))", + topSyntax: "%(list)", attributes: []CheckAttribute{ {name: "name", description: "The name of this agent"}, {name: "version", description: "Version string"}, diff --git a/pkg/snclient/check_tasksched.go b/pkg/snclient/check_tasksched.go index 131f57a9..8fc6f6af 100644 --- a/pkg/snclient/check_tasksched.go +++ b/pkg/snclient/check_tasksched.go @@ -64,8 +64,8 @@ func (l *CheckTasksched) Build() *CheckData { defaultFilter: "enabled = true", defaultCritical: "exit_code < 0", defaultWarning: "exit_code != 0", - detailSyntax: "${uri_clean} (%{most_recent_run_time:date}) exited with ${exit_code}", - topSyntax: "%(status) - ${problem_list}", + detailSyntax: "%(uri_clean) (%(most_recent_run_time:date)) exited with %(exit_code)", + topSyntax: "%(status) - %(problem_list)", okSyntax: "%(status) - All tasks are ok", emptySyntax: "%(status) - No tasks found", emptyState: CheckExitUnknown, diff --git a/pkg/snclient/check_temperature.go b/pkg/snclient/check_temperature.go index eb03c672..628c858d 100644 --- a/pkg/snclient/check_temperature.go +++ b/pkg/snclient/check_temperature.go @@ -43,10 +43,10 @@ func (l *CheckTemperature) Build() *CheckData { State: CheckExitOK, }, defaultFilter: "temperature != 0 and temperature != 1", // seems like disabled sensors return 1.0000 or 0.0000 - defaultWarning: "(min != 0 && temperature < ${min}) || (crit != 0 && temperature > ${crit})", - defaultCritical: "(min != 0 && temperature < ${min}) || (crit != 0 && temperature > ${crit})", - topSyntax: "${status} - ${list}", - detailSyntax: "${sensor}: ${temperature:fmt=%.1f} °C", + defaultWarning: "(min != 0 && temperature < %(min)) || (crit != 0 && temperature > %(crit))", + defaultCritical: "(min != 0 && temperature < %(min)) || (crit != 0 && temperature > %(crit))", + topSyntax: "%(status) - %(list)", + detailSyntax: "%(sensor): %(temperature:fmt=%.1f) °C", emptyState: 3, emptySyntax: "check_temperature failed to find any sensors.", attributes: []CheckAttribute{ diff --git a/pkg/snclient/check_uptime.go b/pkg/snclient/check_uptime.go index 7857df62..1dec1dfb 100644 --- a/pkg/snclient/check_uptime.go +++ b/pkg/snclient/check_uptime.go @@ -31,8 +31,8 @@ func (l *CheckUptime) Build() *CheckData { }, defaultWarning: "uptime < 2d", defaultCritical: "uptime < 1d", - topSyntax: "%(status) - ${list}", - detailSyntax: "uptime: ${uptime}, boot: ${boot | utc}", + topSyntax: "%(status) - %(list)", + detailSyntax: "uptime: %(uptime), boot: %(boot | utc)", attributes: []CheckAttribute{ {name: "uptime", description: "Human readable time since last boot", unit: UDuration}, {name: "uptime_value", description: "Uptime in seconds", unit: UDuration}, diff --git a/pkg/snclient/check_wmi.go b/pkg/snclient/check_wmi.go index c82eb2aa..69deef35 100644 --- a/pkg/snclient/check_wmi.go +++ b/pkg/snclient/check_wmi.go @@ -47,7 +47,7 @@ In order to use this plugin, you need to enable CheckWMI in the Date: Wed, 21 Oct 2026 14:02:27 +0200 Subject: [PATCH 3/3] fix condition parsing with trailing closing bracket --- docs/checks/commands/check_temperature.md | 79 +++++++++++++++++++++++ pkg/snclient/condition.go | 11 +++- pkg/snclient/condition_test.go | 6 ++ 3 files changed, 95 insertions(+), 1 deletion(-) diff --git a/docs/checks/commands/check_temperature.md b/docs/checks/commands/check_temperature.md index e69de29b..f68f2d5b 100644 --- a/docs/checks/commands/check_temperature.md +++ b/docs/checks/commands/check_temperature.md @@ -0,0 +1,79 @@ +--- +title: check_temperature +comment: auto-generated by make docs, do not edit +--- + +Check temperature sensors. + +- [Argument Defaults](#argument-defaults) +- [Attributes](#attributes) +- [Examples](#examples) + +## Implementation + +| Windows | Linux | FreeBSD | MacOSX | +|:------------------:|:------------------:|:-------:|:------------------:| +| :white_check_mark: | :white_check_mark: | | :white_check_mark: | + +## Argument Defaults + +| Argument | Default Value | +| ------------- | ---------------------------------------------------------------------------- | +| filter | temperature != 0 and temperature != 1 | +| warning | (min != 0 && temperature < %(min)) \|\| (crit != 0 && temperature > %(crit)) | +| critical | (min != 0 && temperature < %(min)) \|\| (crit != 0 && temperature > %(crit)) | +| empty-state | 3 (UNKNOWN) | +| empty-syntax | check_temperature failed to find any sensors. | +| top-syntax | %(status) - %(list) | +| ok-syntax | | +| detail-syntax | %(sensor): %(temperature:fmt=%.1f) °C | + +## Check Specific Arguments + +| Argument | Description | +| -------- | --------------------- | +| sensor | Show this sensor only | + +## Attributes + +### Filter Keywords + +these can be used in filters and thresholds (along with the default attributes): + +| Attribute | Description | +| ----------- | ---------------------------------------------- | +| sensor | full name of this sensor, e.g. coretemp_core_0 | +| name | name of this sensor, e.g. coretemp | +| label | label for this sensor, e.g. core 0 | +| temperature | current temperature | +| crit | critical value supplied from sensor | +| max | max value supplied from sensor | +| min | min value supplied from sensor | + +## Examples + +### Default Check + + check_temperature + OK - Package id 0: 65.0 °C, Core 0: 62.0 °C, Core 1: 61.0 °C, Core 2: 65.0 °C |... + +Show all temperature sensors and apply custom thresholds: + + check_temperature filter=none warn="temperature > 85" crit="temperature > 90" + OK - Package id 0: 65.0 °C, Core 0: 62.0 °C, Core 1: 61.0 °C, Core 2: 65.0 °C |... + +### Example using check_snclient and Naemon + +Naemon Config + + define command{ + command_name check_snclient + command_line $USER1$/check_snclient -k -p 'your-password' -u 'https://$HOSTADDRESS$:8443' $ARG1$ $ARG2$ + } + + define service { + host_name testhost + service_description check_temperature + use generic-service + check_command check_snclient!check_temperature! + } diff --git a/pkg/snclient/condition.go b/pkg/snclient/condition.go index e5b4e647..ac6befe6 100644 --- a/pkg/snclient/condition.go +++ b/pkg/snclient/condition.go @@ -728,8 +728,17 @@ func (c *Condition) conditionValue(token []string) (remaining []string, err erro str := token[0] token = token[1:] + macroEnd := 0 + if strings.HasPrefix(str, "%(") || strings.HasPrefix(str, "$(") { + parts, splitErr := splitToken(str, macroSplitBy) + if splitErr != nil { + return nil, splitErr + } + macroEnd = len(parts[0]) + } + // check for trailing closing brackets - for strings.HasSuffix(str, ")") { + for len(str) > macroEnd && strings.HasSuffix(str, ")") { str = strings.TrimSuffix(str, ")") token = append([]string{")"}, token...) } diff --git a/pkg/snclient/condition_test.go b/pkg/snclient/condition_test.go index 7eb41cdc..d17c607d 100644 --- a/pkg/snclient/condition_test.go +++ b/pkg/snclient/condition_test.go @@ -15,6 +15,10 @@ func TestConditionParse(t *testing.T) { }{ {"none", &Condition{isNone: true}}, {"load > 95%", &Condition{keyword: "load", operator: Greater, value: "95", unit: "%"}}, + {"temperature > %(crit)", &Condition{keyword: "temperature", operator: Greater, value: "%(crit)"}}, + {"(temperature > %(crit))", &Condition{keyword: "temperature", operator: Greater, value: "%(crit)"}}, + {"((temperature > %(crit)))", &Condition{keyword: "temperature", operator: Greater, value: "%(crit)"}}, + {"(temperature > $(crit))", &Condition{keyword: "temperature", operator: Greater, value: "$(crit)"}}, {"used > 90GB", &Condition{keyword: "used", operator: Greater, value: "90000000000", unit: "B"}}, {"used>90B", &Condition{keyword: "used", operator: Greater, value: "90", unit: "B"}}, {"used >= 90GiB", &Condition{keyword: "used", operator: GreaterEqual, value: "96636764160", unit: "B"}}, @@ -132,6 +136,8 @@ func TestConditionParseErrors(t *testing.T) { {"(a > 1 or b > 1"}, {"((a > 1 or b > 1)"}, {"a > 1 ) 1)"}, + {"temperature > %(crit"}, + {"temperature > %(crit))"}, {"state in ('a', 'b',)"}, {"state in ('a', 'b',"}, {"state in ('a', 'b'"},