API for host and service templates
API for host and service templates
I don't see an API for listing, getting, creating, and updating host and service templates. Does one exist?
Re: API for host and service templates
There isn't currently an endpoint for these, I have created a feature request on your behalf:
Please keep in mind that the decision to implement the enhancement is at the discretion of our development team.
Actually, now that I'm testing this out you can submit a standard API post to the config/services and config/hosts endpoints with these changed/added:
For hosts:
For services:
For example:
- Note: You may need to URLEncode the TEMPLATEDESC and/or YOURTEMPLATENAME if they have special characters/spaces in them:
https://meyerweb.com/eric/tools/dencoder/
For host templates:
For service templates:
Code: Select all
FR: XI - API - Add host/service templates endpointsActually, now that I'm testing this out you can submit a standard API post to the config/services and config/hosts endpoints with these changed/added:
For hosts:
Code: Select all
host_name=&address=&service_description=YOURTEMPLATEDESCRIPTION&name=YOURTEMPLATENAME®ister=0Code: Select all
host_name=&service_description=YOURTEMPLATEDESCRIPTION&name=YOURTEMPLATENAME®ister=0- Note: You may need to URLEncode the TEMPLATEDESC and/or YOURTEMPLATENAME if they have special characters/spaces in them:
https://meyerweb.com/eric/tools/dencoder/
For host templates:
Code: Select all
curl -k -L -XPOST "http://YOURXISERVER/nagiosxi/api/v1/config/host?apikey=XXXXXXXX&pretty=1" -d "host_name=&address=&check_command=check_ping\!3000,80%\!5000,100%&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&name=YOURTEMPLATENAME®ister=0&applyconfig=1"Code: Select all
curl -k -L -XPOST "http://YOURXISERVER/nagiosxi/api/v1/config/service?apikey=XXXXXXXX&pretty=1" -d "host_name=&service_description=TEMPLATEDESC&check_command=check_ping\!3000,80%\!5000,100%&check_interval=5&retry_interval=5&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7&name=YOURTEMPLATENAME®ister=0&applyconfig=1"Re: API for host and service templates
I'm trying an API call against config/host with the filter of register=0 and I'm not getting back the host templates. So it looks like this only supports creating host templates but not retrieving them?
Re: API for host and service templates
You are correct, development will need to implement that functionality as it doesn't currently support it for the GET, I have updated the feature request again to let them know it's still needed.