Skip to content

Commit

Permalink
16901 FIX nagios-plugins:check_ping: custom-command not mapped to 'ch…
Browse files Browse the repository at this point in the history
…eck_ping' resulting in wrong time units displayed

Having an 'Integrate Nagios plug-ins' rule configured to call
'check_ping' but having the actual value for 'Command line' not start
with 'check_ping' or './check_ping' wouldn't have it recognized
correctly resulting in ms wrongly interpreted as seconds.
This change also allows the command to contain '/check_ping' in order to
recognize more ways to write the custom command and thus displaying
correct units.

SUP-21238

Change-Id: Iac2987ffbde8c5d2b5a91495a1d5a7528b96646a
  • Loading branch information
Frans Fürst committed Jan 10, 2025
1 parent b0c63f3 commit 442d30b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
14 changes: 14 additions & 0 deletions .werks/16901
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Title: nagios-plugins:check_ping: custom-command not mapped to 'check_ping' resulting in wrong time units displayed
Class: fix
Compatible: compat
Component: checks
Date: 1731940191
Edition: cre
Level: 1
Version: 2.2.0p38

Having an 'Integrate Nagios plug-ins' rule configured to call 'check_ping' but having the actual
value for 'Command line' not start with 'check_ping' or './check_ping' wouldn't have it recognized
correctly resulting in ms wrongly interpreted as seconds.
This change also allows the command to contain '/check_ping' in order to recognize more ways
to write the custom command and thus displaying correct units.
3 changes: 2 additions & 1 deletion cmk/gui/plugins/metrics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,8 @@ def _parse_check_command(check_command: str) -> str:
# This function handles very special and known cases.
parts = check_command.split("!", 1)
if parts[0] == "check-mk-custom" and len(parts) >= 2:
if parts[1].startswith("check_ping") or parts[1].startswith("./check_ping"):
# re.search(r"(^|/)check_ping(\s|$)", parts[1]) would be better..
if parts[1].startswith("check_ping") or "/check_ping" in parts[1]:
return "check_ping"
return parts[0]

Expand Down

0 comments on commit 442d30b

Please sign in to comment.