CMK version: 2.0.0p20
OS version: Centos 7
Error message: Downtime not set
If I set the downtime with this script, the status of the host says
Host in downtime no
but in the view downtimes of the host it says
Can somebody please help me?
#!/bin/bash
HOST_NAME="CHECKMKSERVER"
SITE_NAME="test"
API_URL="https://$HOST_NAME/$SITE_NAME/check_mk/api/1.0"
USERNAME="USERNAME"
PASSWORD="PASSWORD"
out=$(
curl --insecure -v\
--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": "Test-Downtime",
"downtime_type": "host",
"duration": 3600,
"end_time": "2022-05-03T12:00:00Z",
"host_name": "azubi-test1.interhyp-linuxdmz.de",
"recur": "fixed",
"start_time": "2022-05-01T11:16:00Z"
}' \
"$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}')
# For indentation, please install 'jq' (JSON query tool)
echo "$resp" | jq
# echo "$resp"
if [[ $code -lt 400 ]]; then
echo "OK"
exit 0
else
echo "Request error"
exit 1
fi
The output is
} [data not shown]
* upload completely sent off: 292 out of 292 bytes
< HTTP/1.1 204 NO CONTENT
< Date: Mon, 02 May 2022 12:20:24 GMT
< Server: Apache
< Content-Security-Policy: default-src 'self' 'unsafe-inline' 'unsafe-eval' ssh: rdp:; img-src 'self' data: https://*.tile.openstreetmap.org/ ; connect-src 'self' https://crash.checkmk.com/ https://license.checkmk.com/api/upload ; frame-ancestors 'self' ; base-uri 'self'; form-action 'self' javascript: 'unsafe-inline'; object-src 'self'; worker-src 'self' blob:
< X-Content-Type-Options: nosniff
< ETag: "da39a3ee5e6b4b0d3255bfef95601890afd80709"
< Content-Type: None
<
100 292 0 0 100 292 0 652 --:--:-- --:--:-- --:--:-- 653
* Connection #0 to host demucvm-checkmk-test1.interhyp-infralinuxdmz.de left intact
OK