REST API Examples

new in release v2.24

Thruk offers a rest api to expose various aspects of Thruk itself and livestatus information.

Read more about the REST API itself. This page contains some useful reallife examples.

Simple Host List

Fetch list of all host names:

  %> thruk r /csv/hosts?columns=name

or by curl:

  %> curl -g 'http://user:password@localhost/thruk/r/csv/hosts?columns=name'

Sending Commands

Add Service Downtime

Putting a service into downtime can be done by either the thruk cli tool:

  %> thruk r -d "start_time=now" -d "end_time=+60m" -d "comment_data='downtime comment'" '/services/<host>/<svc>/cmd/schedule_svc_downtime'

or by sending a http request, for example with curl:

  %> curl -d "start_time=now" -d "end_time=+60m" -d "comment_data='downtime comment'" http://0:3000/thruk/r/services/<host>/<svc>/cmd/schedule_svc_downtime

Note that you don’t have to set all parameters, only the required ones are neccessary. You can use relative arguments for the start- and end-time. For example now will be replaced with the current timestamp while +60m will be 60 minutes in the future.

Read more about relative timestamps.

start_time is optional and will be set to the current timestamp.

end_time is optional as well and will be set to the default downtime_duration.

This leaves a single required argument with the downtime comment:

  %> curl -d "comment_data='downtime comment'" http://0:3000/thruk/r/services/<host>/<svc>/cmd/schedule_svc_downtime
Edit page on GitHub