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