Plugin and semicolon in argument

How can I pass a parameter containing a semicolon to a plugin without Nagios interpreting it as a separator?
cmk -N:

check_mk_active-vectorius!–username test --password test;1234 --check-version --warn 1.3.14 --crit 0.0.1 --base-url ``http://test:1234/admin/info

Here is my Wato definition

‘auth’ : DictElement(
parameter_form=Dictionary(
elements={
‘user’: DictElement(
parameter_form=String(
title=Title(“Username”),
help_text=Help(‘Username for basic authentication’),
),
required=True,
),
‘password’: DictElement(
parameter_form=Password(
title=Title(“Password”),
help_text=Help(‘Password for basic authentication’),
migrate=migrate_to_password,
),
required=True,
),
},
title=Title(‘Authentication’),
),

Hi,

the semicolon issue is a known limitation of the classic Nagios command line format,
where ; acts as a separator. The fix is to use the Secret mechanism in your
server_side_calls plugin instead of passing the password as a plain string.

In your server_side_calls file, pass the password as a Secret object in
command_arguments:

from cmk.server_side_calls.v1 import ActiveCheckCommand, ActiveCheckConfig, Secret

def generate_commands(params, host_config):
    yield ActiveCheckCommand(
        service_description="Vectorius",
        command_arguments=[
            "--username", params["auth"]["user"],
            "--password", params["auth"]["password"],  # Secret object, not str
            "--base-url", params["base_url"],
        ],
    )

Checkmk will then shell-escape the password properly before constructing the command
line, which means special characters like ;, !, $ etc. are handled safely.

Your ruleset definition with Password(migrate=migrate_to_password) is already
correct — just make sure you’re passing the value directly as a Secret and not
calling .unsafe() on it (which would bypass the escaping).

Reference:

Best regards

1 Like

Super, danke !!!
Hat funktioniert

1 Like

Wie würde @Sara sagen
Hallo!

Wenn Ihnen eine der Antworten bei der Lösung Ihrer Frage geholfen hat, markieren Sie diese Antwort doch als Lösung. Auf diese Weise bedanken Sie sich bei der Person, die Ihnen geholfen hat, und markieren die Frage gleichzeitig als gelöst. Das hilft wiederum anderen, die auf diese Frage stoßen.

Vielen Dank!