I miss Monitoring section in REST API

Checkmk Raw Edition 2.1.0p1
Windows Server 2019

I want to get server error via the rest api, to show them in a mobile app.
In teh documentation I found the section monitoring - host status via ‘domain-types/host/’
but in the api swagger there is no entry with this route. Does this version not support theese calls or am I doing something wrong?

Regards Mario

You are using an old Patch level, this could be the reason.

Can you update and Check Again?

I’ll try and give feedback. Thanks for the hint.

We updated to 2.1.0P16 and the API functions are still not there.
Any other ideas how I can get the hosts monitoing data?

Host status is definitely in there . It’s basically doing a Livestatus query with the filters of your choice. There are also some nice examples with which you can see more about host status.

If something doesn’t work, then maybe a screenshot of what you see at the moment will be quite helpful.

I thought this function from the API Documentation would be the correct one:
(http://“myurl”/checkmk/check_mk/api/v0/domain-types/host/collections/all)

but in the Swagger UI I can not find this function.

I manually called the function in the browser, and it worked, but where in the response can I see the hosts status?

  {
     "links":[
        {
           "domainType":"link",
           "rel":"self",
           "href":"http://10.25.47.218/checkmk/check_mk/api/1.0/objects/host/hostname",
           "method":"GET",
           "type":"application/json"
        }
     ],
     "domainType":"dict",
     "id":"hostname",
     "title":"hostname",
     "members":{
        
     },
     "extensions":{
        "name":"hostname"
     }
  },

As far as i know, it is not possible to use the host state query with the Swagger GUI.
@deus82ex at the “host/collections/all” endpoint is the field query missing. Correctly it is shown at “service/collections/all”.
What works is the example from the API doc to fetch the status.

resp = session.get(
    f"{API_URL}/domain-types/host/collections/all",
    params={
        "query": '{"op": "!=", "left": "state", "right": "1"}',
        "columns": ['name', 'state', 'alias', 'contacts'],
    },
)

This will produce a list of all hosts with not state 1 and with some columns in the output.
Output looks like this.

1 Like

Here: cmdb-syncer/checkmk_configuration.py at main · Bastian-Kuhn/cmdb-syncer · GitHub from line 165 on you see an example how I use the api to query status data in python.

1 Like

The request returns 400

http://ip/checkmk/check_mk/api/v0/domain-types/host/collections/all?query={"op": "!=", "left": "state", "right": "1"}&columns=['name', 'state', 'alias', 'contacts']

{
    "title": "Bad Request",
    "status": 400,
    "detail": "These fields have problems: columns",
    "fields": {
        "columns": [
            "Not a valid list."
        ]
    }
}

I found the solution: Get data over 2.0 API - #2 by lars.getwan
there must not be a columns array but every column for itsself, and at least two columns.