From ca658816e869ce3772cb68bf2a9a00171a34203e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Fra=C3=9F?= Date: Mon, 24 Apr 2023 12:19:10 +0200 Subject: [PATCH] =?UTF-8?q?[add]=20"custom"-Feld=20f=C3=BCr=20http=5Freque?= =?UTF-8?q?st-Pr=C3=BCfung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/hmdl.schema.json | 8 ++++++++ examples/http_request.hmdl.json | 20 ++++++++++++++++++++ examples/main.hmdl.json | 2 +- source/logic/checks/http_request.py | 7 +++++++ 4 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 examples/http_request.hmdl.json diff --git a/doc/hmdl.schema.json b/doc/hmdl.schema.json index 4a2393f..8b39804 100644 --- a/doc/hmdl.schema.json +++ b/doc/hmdl.schema.json @@ -589,6 +589,10 @@ "host": { "type": "string" }, + "port": { + "type": "integer", + "default": 443 + }, "strict": { "description": "whether a violation of this check shall be leveled as critical instead of concerning", "type": "boolean", @@ -689,6 +693,10 @@ "description": "whether a violation of this check shall be leveled as critical instead of concerning", "type": "boolean", "default": true + }, + "custom": { + "description": "custom data, which shall be attached to notifications", + "default": null } }, "required": [ diff --git a/examples/http_request.hmdl.json b/examples/http_request.hmdl.json new file mode 100644 index 0000000..f27a706 --- /dev/null +++ b/examples/http_request.hmdl.json @@ -0,0 +1,20 @@ +{ + "checks": [ + { + "name": "test", + "kind": "http_request", + "parameters": { + "request": { + "target": "http://ich-bin-keine-domain.org" + }, + "custom": { + "foo": true, + "bar": { + "baz": "BAZ", + "qux": 2.718 + } + } + } + } + ] +} diff --git a/examples/main.hmdl.json b/examples/main.hmdl.json index 99c1cf3..d7f7727 100644 --- a/examples/main.hmdl.json +++ b/examples/main.hmdl.json @@ -15,6 +15,6 @@ ] }, "includes": [ - "tls_certificate.hmdl.json" + "http_request.hmdl.json" ] } diff --git a/source/logic/checks/http_request.py b/source/logic/checks/http_request.py index 4ecc923..2e78b49 100644 --- a/source/logic/checks/http_request.py +++ b/source/logic/checks/http_request.py @@ -69,6 +69,10 @@ class implementation_check_kind_http_request(interface_check_kind): "type": "boolean", "default": True }, + "custom": { + "description": "custom data, which shall be attached to notifications", + "default": None + }, }, "required": [ "request" @@ -90,6 +94,7 @@ class implementation_check_kind_http_request(interface_check_kind): "status_code": 200 }, "strict": True, + "custom": None, }, node, True @@ -139,6 +144,7 @@ class implementation_check_kind_http_request(interface_check_kind): "faults": [ translation_get("checks.http_request.request_failed"), ], + "custom": parameters["custom"], } } else: @@ -204,6 +210,7 @@ class implementation_check_kind_http_request(interface_check_kind): # "body": response.text, }, "faults": faults, + "custom": parameters["custom"], } }