REST API is not having command end point.
REST API is not having command end point.
Am looking into the REST API implementation and it seems endpoint for running nagios command was not present or missing for e.g. disable/enable service or host notification, adding comment etc.
is it something planed for future release or the endpoints are not exposed due to some reason ?
Thanks,
Pradeep
is it something planed for future release or the endpoints are not exposed due to some reason ?
Thanks,
Pradeep
Re: REST API is not having command end point.
You should be able to enable/disable notifications via a REST API command, for example:
The command above should disable notifications on localhost. You can re-enable them by running:
Code: Select all
curl -XPOST "http://192.168.x.x/nagiosxi/api/v1/config/host?apikey=lfhpn9vu&pretty=1" -d "host_name=localhost&address=127.0.0.1&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7¬ifications_enabled=0&applyconfig=1"
Code: Select all
curl -XPOST "http://192.168.x.x/nagiosxi/api/v1/config/host?apikey=lfhpn9vu&pretty=1" -d "host_name=localhost&address=127.0.0.1&max_check_attempts=2&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7¬ifications_enabled=1&applyconfig=1"
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: REST API is not having command end point.
Hi,
Thanks for the response, but the POST request you have mention will disable and enable notification of all service under host. Sometime we need to disable notification of single service under particular host e.g. http or ntp etc.
So is there any plan to support the above ? am looking something like below
Enable:-
curl -XPOST "http://192.168.x.x/nagiosxi/api/v1/obje ... u&pretty=1" -d "host_name=node01&service_name=http&action=enable&comment=Site Update"
Disable:-
curl -XPOST "http://192.168.x.x/nagiosxi/api/v1/obje ... u&pretty=1" -d "host_name=node01&service_name=http&action=disable&comment=Site Update"
Thanks,
-Pradeep
Thanks for the response, but the POST request you have mention will disable and enable notification of all service under host. Sometime we need to disable notification of single service under particular host e.g. http or ntp etc.
So is there any plan to support the above ? am looking something like below
Enable:-
curl -XPOST "http://192.168.x.x/nagiosxi/api/v1/obje ... u&pretty=1" -d "host_name=node01&service_name=http&action=enable&comment=Site Update"
Disable:-
curl -XPOST "http://192.168.x.x/nagiosxi/api/v1/obje ... u&pretty=1" -d "host_name=node01&service_name=http&action=disable&comment=Site Update"
Thanks,
-Pradeep
Re: REST API is not having command end point.
This is not true. The example command I showed you will disable notifications on localhost only. This will not affect any of the services.Thanks for the response, but the POST request you have mention will disable and enable notification of all service under host.
Here's another example, showing how to disable notifications on the HTTP service on localhost:Sometime we need to disable notification of single service under particular host e.g. http or ntp etc.
Code: Select all
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/service?apikey=lfhpn9vu&pretty=1" -d "host_name=localhost&service_description=HTTP&check_command=check_http&check_interval=5&retry_interval=1&max_check_attempts=4&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7¬ifications_enabled=0&applyconfig=1"Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: REST API is not having command end point.
Sorry am not clear enough in my pervious response, what i meant was it will disable all notification of localhost.Thanks for the response, but the POST request you have mention will disable and enable notification of all service under host.
Code: Select all
curl -XPOST "http://x.x.x.x/nagiosxi/api/v1/config/service?apikey=lfhpn9vu&pretty=1" -d "host_name=localhost&service_description=HTTP&check_command=check_http&check_interval=5&retry_interval=1&max_check_attempts=4&check_period=24x7&contacts=nagiosadmin¬ification_interval=5¬ification_period=24x7¬ifications_enabled=0&applyconfig=1". Please correct me if am wrong.notifications_enabled=0 | 1
Thanks,
Re: REST API is not having command end point.
You are correct. The "curl -XPOST" is used for adding objects. The "curl -XDELETE" is used for deleting objects.I think we are trying recreate the particular e.g HTTP service every time we want to disable or enable with only one value change
So in order to "modify" an object, you basically will need to "recreate" it. Simply modifying objects via the REST API is not available at this time as far as I know but it may be added in the future.Backend API - Config Reference
With the new API in Nagios XI 5 we linked it up directly with the Core Config Manager. This allows creation and deletion of items directly from the API. This API section is admin only.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: REST API is not having command end point.
Thanks for the response. I have applied a patch on "utils-api.inc.php" to expose only disable and enable service notification with comment support.
Example:-
Please review the patch attached and let me know if you can make it officially release ?
Example:-
Code: Select all
curl -XPOST "http://192.168.x.x/nagiosxi/api/v1/objects/alert?apikey=evk5jn6r6ehmgf" -d "host_name=node01&service_name=HTTP&action=enable&comment=Enable\ service\ notification"Code: Select all
curl -XPOST "http://192.168.x.x/nagiosxi/api/v1/objects/alert?apikey=evk5jn6r6ehmgf" -d "host_name=node01&service_name=HTTP&action=disable&comment=Disable\ service\ notification"Please review the patch attached and let me know if you can make it officially release ?
You do not have the required permissions to view the files attached to this post.
Re: REST API is not having command end point.
Thanks, pmishra! I forwarded your patch to our developers. We really appreciate your input!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: REST API is not having command end point.
You welcome, am looking forward to hear from you and developer team.
Do let me know if you or the team need any fix or found any issue on the current patch.
Thanks,
Pradeep
Do let me know if you or the team need any fix or found any issue on the current patch.
Thanks,
Pradeep
Re: REST API is not having command end point.
I'll leave the thread open for discussion, but I do have to ask that it not gets bumped unless an issue is found. We use a dashboard system here to make sure SLA is being met, and when things that are "resolved" get bumped up, it make it look like there is still an issue.
Thank you again for your contribution! We appreciate our community more than I can express.
Thank you again for your contribution! We appreciate our community more than I can express.
Former Nagios Employee.
me.
me.