如何在 thruk api 调用中转义/在服务名称中

问题描述

我有很多名称中带有正斜杠的 nagios 服务。当我尝试通过 thruk api 确认服务时,它返回如下错误

AUTO

服务名称request: http://<thruk_url>/r/v1/services/test-host/check_disk_%2Fvar/cmd/ackNowledge_svc_problem response: /r/v1/services/test-host/check_disk_/var/cmd/ackNowledge_svc_problem was not found on this server. 我有很多这样的服务,因此重命名它们并不是一个简单的解决方案。

解决方法

有一个通用命令端点,如下所述: https://thruk.org/documentation/rest_commands.html#_generic-command-endpoint

    %> curl -H "X-Thruk-Auth-Key: ****" \
            -d "cmd=acknowledge_svc_problem" \
            -d "host=hostname" \
            -d "service=servicedescription" \
            -d "comment_data=test" \
          'http://localhost/thruk/r/cmd'