Hi,
Is there a way to create an active HTTP check via the REST API or is set_ruleset
via HTTP-API the only way?
Regards,
Hi,
Is there a way to create an active HTTP check via the REST API or is set_ruleset
via HTTP-API the only way?
Regards,
Currently editing rulsets is not available in the REST-API, but only in the WATO-API.
This is because JSON does not have the data type Tuple, which is needed for the ruleset representation in Python.
AFAIK the developers are working on a solution.
In the meantime, I want to “patch” the ruleset with the help of python and then write it back.
So, I retrieve the data with PHP curl: ...&action=get_ruleset&output_format=python
. POST request
is {"ruleset_name":"active_checks:http"}
.
That returns me: {'result_code': 0, 'result': {'ruleset': {'': [750629c9-6418-45ca-9201-d50874c6df30', 'value': {'name': 'osiris-owa', 'host': {....
the complete ruleset.
Then I want to read that to a helper python script to work with it:
#!/usr/bin/env python3
import sys
import ast
with open(sys.argv[1], "r") as data:
dictionary = ast.literal_eval(data.read())
print(type(dictionary))
print(dictionary)
But all I get is:
Traceback (most recent call last):
File "checkmk.py", line 7, in <module>
dictionary = ast.literal_eval(data.read())
File "/usr/lib/python3.6/ast.py", line 48, in literal_eval
node_or_string = parse(node_or_string, mode='eval')
File "/usr/lib/python3.6/ast.py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "<unknown>", line 1
{'result_code': 0, 'result': {'ruleset': {'': [75062...truncated...ons': {'description': 'AZS Zeitsystem SSL-Zertifikat'}}]}, 'configuration_hash': '2173901dfcd47611dbdc615914f44e2b'}}
^
SyntaxError: invalid syntax
When I change the string, the ^ pointer moves as well, so its not a specific char imho.
Anyone you can assist me?
I decided to wait until the REST Api is capable of this. With 2.1.0 there were more changes. I did not updated, yet - can anyone tell me if my requested rulesets are now available via REST-API?
Right now I’m using 2.1.0p9, it returns
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
nobody@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
on request "ruleset": "active_checks:http",
Seem like creating a new active HTTP check via API still not working!!!
Creating an active http check worked recently but I did not tested latest release (p11). Will check both with latest release.
No, the REST API still works with adding new active checks:
{"ruleset":"active_checks:http","folder":"\/folder","value_raw":"{'name': '[vHostCtrl] myuri', 'host': {'address': 'myuri', 'virthost': 'myuri'}, 'mode': ('url', {'onredirect': 'follow'})}","conditions":{"host_name":{"match_on":["server"],"operator":"one_of"}},"properties":{"description":"__vhostctrl_version__1"}}
to: check_mk/api/1.0//domain-types/rule/collections/all
.
results to:
But my other issue still persists via REST: [REST API] Activate changes not working: "Currently there are no changes to activate."
Exception 'Exception' with message 'Activation failed! {"title": "The operation has failed.", "status": 422, "detail": "Currently there are no changes to activate."}'
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.