...
Code Block |
---|
|
"domainType": "host_config",
"id": "klappedieerste",
"title": "klappedieerste",
"members": {},
"extensions": {
"folder": "",
"attributes": {
"ipaddress": "127.0.0.1",
"snmp_community": {
"type": "v1_v2_community",
"community": "publicenemy"
},
"labels": {
"_mpac_spool_new": "/var/spool/mpac/remote/messages/new"
},
"meta_data": {
"created_at": "2021-01-06T07:15:17+00:00",
"updated_at": "2022-03-31T10:14:32.969304+00:00",
"created_by": "cmkadmin"
},
"tag_criticality": "prod",
"tag_action_ssh": "action_ssh",
"tag_agent": "all-agents",
"tag_snmp_ds": "snmp-v2"
},
"effective_attributes": null,
"is_cluster": false,
"is_offline": false,
"cluster_nodes": null
} |
Restrictions
Custom attributes of a host are currently only visible when setting "effective_attributes=true".
Services
Showing a particular service
...
Code Block |
---|
language | bash |
---|
theme | RDark |
---|
title | Complex Query to set a host downtime |
---|
|
HOST_NAME="localhost"
PROTOCOL="https"
USERNAME="automation"
SITE_NAME="klapplg"
QUERY_HOST="klappedieerste"
PASSWORD="********"
API_URL="$PROTOCOL://$HOST_NAME/$SITE_NAME/check_mk/api/1.0"
out=$(
curl \
--request POST \
--write-out "\nxxx-status_code=%{http_code}\n" \
--header "Authorization: Bearer $USERNAME $PASSWORD" \
--header "Accept: application/json" \
--header "Content-Type: application/json" \
--data '{"comment": "Schedule downtime on host which are in two groups",
"downtime_type": "host_by_query",
"duration": 0,
"end_time": "2022-05-03T13:18:40Z",
"recur": "fixed",
"start_time": "2022-05-03T11:48:40Z",
"query": {"op": "and", "expr":[{"op": ">=", "left": "groups", "right": "hostgroupA"}, {"op": ">=", "left": "groups", "right": "hostgroupB"}]}}' \
"$API_URL/domain-types/downtime/collections/host")
resp=$( echo "${out}" | grep -v "xxx-status_code" )
code=$( echo "${out}" | awk -F"=" '/^xxx-status_code/ {print $2}')
echo "$resp" | jq
if [[ $code -lt 400 ]]; then echo "OK"; else echo "Request error"; fi |
Restrictions
- It's impossible to restrict the output to a single column; you must request at least two columns.
- It's impossible to query data from columns of the type "blob", like "mk_inventory".
Related articles
Filter by label (Content by label) |
---|
showLabels | false |
---|
max | 5 |
---|
spaces | KB |
---|
showSpace | false |
---|
sort | modified |
---|
reverse | true |
---|
type | page |
---|
cql | label in ( "kb-how-to-article" , "howto" ) and type = "page" and space = "KB" |
---|
labels | kb-how-to-article |
---|
|
...