Wenn ich die “properties”-Zeile aus dem Aufruf rausnehme wirds noch schlimmer:
#!/bin/bash
HOST_NAME="myhostname.fqdn"
SITE_NAME="mytestsite"
API_URL="https://$HOST_NAME/$SITE_NAME/check_mk/api/1.0"
USERNAME="automation"
PASSWORD="geheim"
# Requires httpie version >= 3
http POST "$API_URL/domain-types/rule/collections/all" \
"Authorization: Bearer $USERNAME $PASSWORD" \
"Accept: application/json" \
'Content-Type:application/json' \
ruleset='custom_checks'\
folder='~testhosts'\
value_raw="{'command_line': 'check_miwu_http -U https://google.de ', 'has_perfdata': True, 'service_description': 'check_google'}"
Das Ergebnis ist ein Crash:
HTTP/1.1 500 INTERNAL SERVER ERROR
Connection: close
Content-Length: 4625
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/verify; frame-ancestors 'self' ; base-uri 'self'; form-action 'self' javascript: 'unsafe-inline'; object-src 'self'; worker-src 'self' blob:
Content-Type: application/problem+json
Date: Tue, 27 Feb 2024 09:34:59 GMT
Permissions-Policy: accelerometer=(), autoplay=(), camera=(), encrypted-media=(), fullscreen=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), usb=()
Referrer-Policy: origin-when-cross-origin
Server: Apache
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
X-Permitted-Cross-Domain-Policies: none
X-XSS-Protection: 1; mode=block
{
"detail": "KeyError: conditions. Crash report generated. Please submit.",
"ext": {
"core": "cmc",
"crash_type": "rest_api",
"details": {
"check_mk_info": {
"check_mk_user": {
"authorized_sites": [
"mytestsite",
"mytestsite_slave"
],
"user_id": "automation",
"user_roles": [
"admin"
]
},
"site": "mytestsite"
},
"crash_report_url": {
"href": "http://myhostname.fqdn/mytestsite/check_mk/crash.py?crash_id=7aba421a-d553-11ee-9b98-005056a2a9c5&site=mytestsite",
"method": "get",
"rel": "cmk/crash-report",
"type": "text/html"
},
"request_info": {
"data_received": {
"folder": "~testhosts",
"ruleset": "custom_checks",
"value_raw": "{'command_line': 'check_miwu_http -U https://google.de ', 'has_perfdata': True, 'service_description': 'sc_https_google'}"
},
"endpoint_url": "/mytestsite/check_mk/api/1.0/domain-types/rule/collections/all",
"headers": {
"accept": "application/json",
"content_type": "application/json"
},
"method": "POST"
}
},
"edition": "cee",
"exc_traceback": [
"Traceback (most recent call last):",
" File \"/omd/sites/mytestsite/lib/python3/cmk/gui/wsgi/applications/rest_api.py\", line 435, in wsgi_app",
" return wsgi_endpoint(environ, start_response)",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
" File \"/omd/sites/mytestsite/lib/python3/cmk/gui/wsgi/applications/utils.py\", line 47, in __call__",
" return self.wsgi_app(environ, start_response)",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
" File \"/omd/sites/mytestsite/lib/python3/cmk/gui/wsgi/applications/rest_api.py\", line 164, in wsgi_app",
" wsgi_app = self.endpoint.wrapped(ParameterDict(path_args))",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
" File \"/omd/sites/mytestsite/lib/python3/cmk/gui/plugins/openapi/restful_objects/decorators.py\", line 1003, in _wrapper",
" response = func(param)",
" ^^^^^^^^^^^",
" File \"/omd/sites/mytestsite/lib/python3/cmk/gui/plugins/openapi/restful_objects/decorators.py\", line 992, in _validating_wrapper",
" return self._validate_response(response_schema, _params)",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
" File \"/omd/sites/mytestsite/lib/python3/cmk/gui/plugins/openapi/restful_objects/decorators.py\", line 789, in _validate_response",
" response = self.func(_params)",
" ^^^^^^^^^^^^^^^^^^",
" File \"/omd/sites/mytestsite/lib/python3/cmk/gui/plugins/openapi/endpoints/rule/__init__.py\", line 202, in create_rule",
" host_tags=body[\"conditions\"].get(\"host_tags\"),",
" ~~~~^^^^^^^^^^^^^^",
"KeyError: 'conditions'",
""
],
"exc_type": "KeyError",
"exc_value": "conditions",
"id": "7aba421a-d553-11ee-9b98-005056a2a9c5",
"local_vars": "(...)",
"os": "SUSE Linux Enterprise Server 15 SP5",
"python_paths": [
"/omd/sites/mytestsite/local/lib/python3",
"/omd/sites/mytestsite/lib/python3/cloud",
"/omd/sites/mytestsite/lib/python311.zip",
"/omd/sites/mytestsite/lib/python3.11",
"/omd/sites/mytestsite/lib/python3.11/lib-dynload",
"/omd/sites/mytestsite/lib/python3.11/site-packages",
"/omd/sites/mytestsite/lib/python3"
],
"python_version": "3.11.2 (main, Jun 29 2023, 23:24:59) [GCC 12.2.0]",
"time": "2024-02-27T10:35:00.349060",
"version": "2.2.0p9"
},
"status": 500,
"title": "Internal Server Error"
}