简体   繁体   中英

Icinga2 API - get specific hosts from templates

How can i set my filters to get only the hosts from a template, which have a custom variable set to true?

With this curl, im getting all hosts in the template but not the ones, which have set the custom_var true

    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 '.'

Any ideas on how can i get the specific hosts?

Finally got i working. I edited my filter as follows:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM