Page 1 of 1

rest api service check creation add template param

Posted: Wed Nov 25, 2015 7:11 pm
by doneil326
i would like to know if it is possible to use the restapi to create a service and attach it to a template so that i don't have to pass all parameters. something like the below but with a template so that the numerous service checks i am creating have inherited settings, it seems like this should work but it sets the options to 0 or disabled that are ''. Also, how do i get the service name to match the service_description instead of the host_name?

"host_name=#{host_name}&service_description=dev-oracle-query-dw-#{param_row['SUBJECT_AREA']}-#{param_row['SESSION_NAME']}&"\
"check_command=check_ll_oraclequery_dw_batch_single_lldwd_app\!#{param_row['SUBJECT_AREA']}\!#{param_row['SESSION_NAME']}&check_interval=''&retry_interval=''&max_check_attempts=''&check_period=''&contacts=''&notification_interval=''&notification_period=''&use=ll_oraclequery_service_prod_15_min&applyconfig=1"

Re: rest api service check creation add template param

Posted: Wed Nov 25, 2015 8:18 pm
by Box293
Currently this is not possible.

The API wants you to define the variables even though the template includes them.

We have a feature request #7028 pending for this and I will also link this forum thread to the feature request.

Re: rest api service check creation add template param

Posted: Fri Nov 27, 2015 12:23 pm
by doneil326
Is there a way to change the service name when it is created so it doesn't match the hostname?

Re: rest api service check creation add template param

Posted: Sun Nov 29, 2015 10:02 pm
by Box293
Unfortunately not at this point in time.

I created a feature request for this, TASK ID 7101.

Re: rest api service check creation add template param

Posted: Mon Nov 30, 2015 4:29 pm
by doneil326
Thank you for answering my questions. Please close this loop.

Re: rest api service check creation add template param

Posted: Tue Dec 01, 2015 9:39 am
by tmcdonald
Unlocking at the request of @Box293 who said he had some additional input.

Re: rest api service check creation add template param

Posted: Tue Dec 01, 2015 5:07 pm
by Box293
Box293 wrote:Currently this is not possible.

The API wants you to define the variables even though the template includes them.

We have a feature request #7028 pending for this and I will also link this forum thread to the feature request.
@BanditBBS messaged me as he has some info I did not know about.
BanditBBS wrote:It is possible to use the use= to use a template and use the force=1 so it doesn't require all fields!
For example:

Code: Select all

curl -XPOST "http://xitest/nagiosxi/api/v1/config/service?apikey=7gobcg3s&pretty=1" -d "host_name=test_host&service_description=PINGxxxx&use=template_ping_service&force=1&applyconfig=1"
However there was not a way to define the service name.