alerts.py: one merged critical alert for an unavailable cloud key (section 20)
This commit is contained in:
1 parent
e554b30adc
commit
d2bdacd662
1 file changed
+18
-8
@@ -6,7 +6,8 @@ itself.
|
|||||||
|
|
||||||
One saved check covers one key. A key that was not available produces a single
|
One saved check covers one key. A key that was not available produces a single
|
||||||
critical alert, because the remaining checks for that key could not be
|
critical alert, because the remaining checks for that key could not be
|
||||||
performed.
|
performed. For the cloud key the cloud results are derived from availability
|
||||||
|
(section 20), so that one alert mentions both facts.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
CRITICAL = "critical"
|
CRITICAL = "critical"
|
||||||
@@ -14,6 +15,16 @@ INFO = "info"
|
|||||||
|
|
||||||
_SEVERITY_ORDER = {CRITICAL: 0, INFO: 1}
|
_SEVERITY_ORDER = {CRITICAL: 0, INFO: 1}
|
||||||
|
|
||||||
|
_KEY_UNAVAILABLE_MESSAGE = (
|
||||||
|
"This key was not available. Replace the key before continuing; "
|
||||||
|
"the remaining checks for this key cannot be recorded."
|
||||||
|
)
|
||||||
|
_CLOUD_KEY_UNAVAILABLE_MESSAGE = (
|
||||||
|
"This key was not available and the cloud provider is recorded as not operating. "
|
||||||
|
"Check the provider status and replace the key before continuing; "
|
||||||
|
"the remaining checks for this key cannot be recorded."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def build_alerts(record):
|
def build_alerts(record):
|
||||||
"""Return the active alerts for one saved health check.
|
"""Return the active alerts for one saved health check.
|
||||||
@@ -43,13 +54,12 @@ def _key_alerts(key_check):
|
|||||||
source = f"Key {key_check.get('key_number')}: {key_check.get('name')}"
|
source = f"Key {key_check.get('key_number')}: {key_check.get('name')}"
|
||||||
if key_check.get("available") == 0:
|
if key_check.get("available") == 0:
|
||||||
# The remaining checks for this key could not be performed.
|
# The remaining checks for this key could not be performed.
|
||||||
return [_alert(
|
message = (
|
||||||
"key_unavailable",
|
_CLOUD_KEY_UNAVAILABLE_MESSAGE
|
||||||
CRITICAL,
|
if key_check.get("type") == "cloud"
|
||||||
source,
|
else _KEY_UNAVAILABLE_MESSAGE
|
||||||
"This key was not available. Replace the key before continuing; "
|
)
|
||||||
"the remaining checks for this key cannot be recorded.",
|
return [_alert("key_unavailable", CRITICAL, source, message)]
|
||||||
)]
|
|
||||||
|
|
||||||
alerts = []
|
alerts = []
|
||||||
if key_check.get("hardware_works") == 0:
|
if key_check.get("hardware_works") == 0:
|
||||||
|
|||||||
Reference in new issue
Block a user