BUG: SFTP check/test, $HOSTNAME$ macro not replaced - targeted at host with a label but variable hostname

I’m trying to create an SFTP check much like I did with a HTTPs check, using a variable for the hostname, but seemingly this check trates the variable text “$HOSTNAME$” literally, and thus doesn’t work.

And idea or tips to make this work without creating multiple SFTP checks for each host?

Check SFTP service:
Host matching labels: [sftp:yes]

Host name:
$HOSTNAME$
Username:
CheckMK
Password:
Explicit: ******
Service name:
Globalscape SFTP Check
Port:
22
Put file to SFTP server:
Local file:
Remote destination:

Get file from SFTP server:
Remote file:
Local destination:

Service check command check_mk_active-sftp!–host ‘$HOSTNAME$’ --user CheckMK --secret-reference uuid***********************:/omd/sites/Main/var/check_mk/core/helper_config/latest/stored_passwords --port 22 --put-local ‘’ --put-remote ‘’ --get-local ‘’ --get-remote ‘’

Hi Brandon,

check your server_side_calls script, for the hostname it should do something like this:

from cmk.server_side_calls.v1 import (
    ActiveCheckCommand,
    ActiveCheckConfig,
    HostConfig,
    replace_macros,
)

def _generate_command(
    params: SftpParams, host_config: HostConfig
) -> Iterator[ActiveCheckCommand]:

    hostname = replace_macros(params.hostname, host_config.macros)
    ....

It is not his own check. This problem has the integrated SFTP check.

At the moment i have no idea, this is a Bug in the included SFTP check.

ups.. my fault :slight_smile: thanks for correcting me!

Thanks to a colleague in dev, this has already been handled within this werk: Werk #22249: check_sftp: Replace host macros in host name and service name

You can use macros starting with the next patch release for 2.5.0 and 2.4.0