【问题标题】:Icinga2 API - get specific hosts from templatesIcinga2 API - 从模板中获取特定主机
【发布时间】:2018-10-05 07:20:10
【问题描述】:

如何设置过滤器以仅从模板中获取主机,这些主机的自定义变量设置为 true?

通过这个 curl,我得到了模板中的所有主机,但不是那些设置 custom_var 为真的主机

    curl -k -s -u $apiuser:$apipassword -H 'Accept: application/json' -X         
    POST -H 'X-HTTP-Method-Override: GET' https://$url:$port/v1/objects
    /hosts -d '{ "filter": "\"template\" in host.templates",
    "filter_vars": { "custom_var": true } } ' | jq '.'

关于如何获取特定主机的任何想法?

【问题讨论】:

    标签: api curl get icinga2


    【解决方案1】:

    终于让我工作了。我按如下方式编辑了我的过滤器:

       -d '{ "filter": "\"template\" in host.templates && host.vars.custom == true" } ''' | jq '.'
    

    【讨论】:

      猜你喜欢
      • 2021-08-24
      • 1970-01-01
      • 2012-12-07
      • 2023-02-16
      • 2013-03-02
      • 2012-04-12
      • 2019-11-05
      • 2019-07-25
      • 1970-01-01
      相关资源
      最近更新 更多