[mod] made "custom" parameter common for all checks [add] http parameter "follow_redirects"
This commit is contained in:
parent
ca658816e8
commit
dfae9cb4aa
|
|
@ -34,6 +34,11 @@ class implementation_check_kind_http_request(interface_check_kind):
|
|||
"type": "float",
|
||||
"default": 5.0
|
||||
},
|
||||
"follow_redirects": {
|
||||
"description": "whether redirect instructions in responses shall be followend instead of being exposed as result",
|
||||
"type": "boolean",
|
||||
"default": False
|
||||
},
|
||||
"response": {
|
||||
"type": "object",
|
||||
"additionalProperties": False,
|
||||
|
|
@ -69,10 +74,6 @@ 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,11 +91,11 @@ class implementation_check_kind_http_request(interface_check_kind):
|
|||
"method": "GET"
|
||||
},
|
||||
"timeout": 5.0,
|
||||
"follow_redirects": False,
|
||||
"response": {
|
||||
"status_code": 200
|
||||
},
|
||||
"strict": True,
|
||||
"custom": None,
|
||||
},
|
||||
node,
|
||||
True
|
||||
|
|
@ -114,7 +115,8 @@ class implementation_check_kind_http_request(interface_check_kind):
|
|||
try:
|
||||
response = _requests.get(
|
||||
parameters["request"]["target"],
|
||||
timeout = parameters["timeout"]
|
||||
timeout = parameters["timeout"],
|
||||
allow_redirects = parameters["follow_redirects"]
|
||||
)
|
||||
error = None
|
||||
except Exception as error_:
|
||||
|
|
@ -124,7 +126,8 @@ class implementation_check_kind_http_request(interface_check_kind):
|
|||
try:
|
||||
response = _requests.post(
|
||||
parameters["request"]["target"],
|
||||
timeout = parameters["timeout"]
|
||||
timeout = parameters["timeout"],
|
||||
allow_redirects = parameters["follow_redirects"]
|
||||
)
|
||||
error = None
|
||||
except Exception as error_:
|
||||
|
|
@ -144,7 +147,6 @@ class implementation_check_kind_http_request(interface_check_kind):
|
|||
"faults": [
|
||||
translation_get("checks.http_request.request_failed"),
|
||||
],
|
||||
"custom": parameters["custom"],
|
||||
}
|
||||
}
|
||||
else:
|
||||
|
|
@ -210,7 +212,6 @@ class implementation_check_kind_http_request(interface_check_kind):
|
|||
# "body": response.text,
|
||||
},
|
||||
"faults": faults,
|
||||
"custom": parameters["custom"],
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -173,6 +173,10 @@ def conf_schema_root(
|
|||
"enum": [pair[0]]
|
||||
},
|
||||
"parameters": pair[1].parameters_schema(),
|
||||
"custom": {
|
||||
"description": "custom data, which shall be attached to notifications",
|
||||
"default": None,
|
||||
},
|
||||
},
|
||||
"required": [
|
||||
"kind",
|
||||
|
|
@ -300,6 +304,7 @@ def conf_normalize_check(
|
|||
{
|
||||
"title": node["name"],
|
||||
"parameters": {},
|
||||
"custom": None,
|
||||
},
|
||||
),
|
||||
node
|
||||
|
|
@ -328,6 +333,8 @@ def conf_normalize_check(
|
|||
node__["kind"] = node_["kind"]
|
||||
if True:
|
||||
node__["parameters"] = check_kind_implementations[node_["kind"]].normalize_conf_node(node_["parameters"])
|
||||
if ("custom" in node_):
|
||||
node__["custom"] = node_["custom"]
|
||||
return node__
|
||||
|
||||
|
||||
|
|
@ -359,7 +366,7 @@ def conf_normalize_root(
|
|||
string_coin(
|
||||
"ambiguous check names: {{names}}",
|
||||
{
|
||||
"names": ",".join(counts.keys()),
|
||||
"names": ",".join(map(lambda pair: pair[0], fails)),
|
||||
}
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -322,7 +322,14 @@ def main():
|
|||
check_data["name"],
|
||||
check_data,
|
||||
new_item_state,
|
||||
result["info"]
|
||||
dict_merge(
|
||||
(
|
||||
{}
|
||||
if (check_data["custom"] is None) else
|
||||
{"custom": check_data["custom"]}
|
||||
),
|
||||
result["info"]
|
||||
)
|
||||
)
|
||||
|
||||
_os.remove(args.mutex_path)
|
||||
|
|
|
|||
Loading…
Reference in a new issue