[issue-3] [add] conf:reminding_interval [mod] main:heed reminding_interval and last_notification_timestamp
This commit is contained in:
parent
3ae65c08db
commit
554ca49c49
|
|
@ -2,7 +2,8 @@
|
||||||
"defaults": {
|
"defaults": {
|
||||||
"schedule": {
|
"schedule": {
|
||||||
"regular_interval": 10,
|
"regular_interval": 10,
|
||||||
"attentive_interval": 1
|
"attentive_interval": 1,
|
||||||
|
"reminding_interval": 20
|
||||||
},
|
},
|
||||||
"threshold": 1,
|
"threshold": 1,
|
||||||
"notifications": [
|
"notifications": [
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,14 @@ def conf_schema_annoy(
|
||||||
|
|
||||||
|
|
||||||
def conf_schema_interval(
|
def conf_schema_interval(
|
||||||
|
allow_null,
|
||||||
default
|
default
|
||||||
):
|
):
|
||||||
return {
|
return {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{
|
{
|
||||||
"description": "in seconds",
|
"description": "in seconds",
|
||||||
"type": "integer",
|
"type": ("integer" if allow_null else ["null", "integer"]),
|
||||||
"exclusiveMinimum": 0,
|
"exclusiveMinimum": 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -57,8 +58,9 @@ def conf_schema_schedule(
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"additionalProperties": False,
|
"additionalProperties": False,
|
||||||
"properties": {
|
"properties": {
|
||||||
"regular_interval": conf_schema_interval(60 * 60),
|
"regular_interval": conf_schema_interval(False, (60 * 60)),
|
||||||
"attentive_interval": conf_schema_interval(60 * 2),
|
"attentive_interval": conf_schema_interval(False, (60 * 2)),
|
||||||
|
"reminding_interval": conf_schema_interval(True, (60 * 60 * 24)),
|
||||||
},
|
},
|
||||||
"required": [
|
"required": [
|
||||||
],
|
],
|
||||||
|
|
@ -193,21 +195,24 @@ def conf_schema_root(
|
||||||
def conf_normalize_interval(
|
def conf_normalize_interval(
|
||||||
interval_raw
|
interval_raw
|
||||||
):
|
):
|
||||||
if (type(interval_raw) == int):
|
if (interval_raw is None):
|
||||||
return interval_raw
|
return None
|
||||||
elif (type(interval_raw) == str):
|
|
||||||
map_ = {
|
|
||||||
"minute": (60),
|
|
||||||
"hour": (60 * 60),
|
|
||||||
"day": (60 * 60 * 24),
|
|
||||||
"week": (60 * 60 * 24 * 7),
|
|
||||||
}
|
|
||||||
if (interval_raw not in map_):
|
|
||||||
raise ValueError("invalid string interval value: %s" % interval_raw)
|
|
||||||
else:
|
|
||||||
return map_[interval_raw]
|
|
||||||
else:
|
else:
|
||||||
raise ValueError("invalid type for interval value")
|
if (type(interval_raw) == int):
|
||||||
|
return interval_raw
|
||||||
|
elif (type(interval_raw) == str):
|
||||||
|
map_ = {
|
||||||
|
"minute": (60),
|
||||||
|
"hour": (60 * 60),
|
||||||
|
"day": (60 * 60 * 24),
|
||||||
|
"week": (60 * 60 * 24 * 7),
|
||||||
|
}
|
||||||
|
if (interval_raw not in map_):
|
||||||
|
raise ValueError("invalid string interval value: %s" % interval_raw)
|
||||||
|
else:
|
||||||
|
return map_[interval_raw]
|
||||||
|
else:
|
||||||
|
raise ValueError("invalid type for interval value")
|
||||||
|
|
||||||
|
|
||||||
def conf_normalize_schedule(
|
def conf_normalize_schedule(
|
||||||
|
|
@ -217,12 +222,14 @@ def conf_normalize_schedule(
|
||||||
{
|
{
|
||||||
"regular_interval": (60 * 60),
|
"regular_interval": (60 * 60),
|
||||||
"attentive_interval": (60 * 2),
|
"attentive_interval": (60 * 2),
|
||||||
|
"reminding_interval": (60 * 60 * 24),
|
||||||
},
|
},
|
||||||
node
|
node
|
||||||
)
|
)
|
||||||
return {
|
return {
|
||||||
"regular_interval": conf_normalize_interval(node["regular_interval"]),
|
"regular_interval": conf_normalize_interval(node["regular_interval"]),
|
||||||
"attentive_interval": conf_normalize_interval(node["attentive_interval"]),
|
"attentive_interval": conf_normalize_interval(node["attentive_interval"]),
|
||||||
|
"reminding_interval": conf_normalize_interval(node["reminding_interval"]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -251,6 +258,7 @@ def conf_normalize_defaults(
|
||||||
"schedule": {
|
"schedule": {
|
||||||
"regular_interval": (60 * 60),
|
"regular_interval": (60 * 60),
|
||||||
"attentive_interval": (60 * 2),
|
"attentive_interval": (60 * 2),
|
||||||
|
"reminding_interval": (60 * 60 * 24),
|
||||||
},
|
},
|
||||||
"notifications": [
|
"notifications": [
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -266,6 +266,24 @@ def main():
|
||||||
and
|
and
|
||||||
check_data["annoy"]
|
check_data["annoy"]
|
||||||
)
|
)
|
||||||
|
or
|
||||||
|
(
|
||||||
|
(count is None)
|
||||||
|
and
|
||||||
|
(
|
||||||
|
(old_item_state is not None)
|
||||||
|
and
|
||||||
|
(old_item_state["last_notification_timestamp"] is not None)
|
||||||
|
and
|
||||||
|
(check_data["schedule"]["reminding_interval"] is not None)
|
||||||
|
and
|
||||||
|
(
|
||||||
|
(timestamp - old_item_state["last_notification_timestamp"])
|
||||||
|
>=
|
||||||
|
check_data["schedule"]["reminding_interval"]
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
and
|
and
|
||||||
(
|
(
|
||||||
|
|
|
||||||
5
todo.md
5
todo.md
|
|
@ -1,8 +1,5 @@
|
||||||
- parallele Zugriffe auf die Zustands-Datei verhindern
|
- auf DB umstellen?
|
||||||
- mutex?
|
|
||||||
- auf DB umstellen?
|
|
||||||
- Benachrichtigungen versenden, wenn ein Zustand sich wieder normalisiert hat (aber vorher über dem Schwellwert oft nicht OK war)
|
- Benachrichtigungen versenden, wenn ein Zustand sich wieder normalisiert hat (aber vorher über dem Schwellwert oft nicht OK war)
|
||||||
- erneute Benachrichtigung über nicht-OK-Zustand nach einer Weile (siehe https://gitlab.greenscale.de/tools/heimdall/-/issues/3)
|
|
||||||
- längere Statistiken über Metriken führen um auch Anstiege/Abfälle auszuwerten (z.B. "Speicherplatzverbrauch innerhalb einer Woche um 5GB gestiegen")
|
- längere Statistiken über Metriken führen um auch Anstiege/Abfälle auszuwerten (z.B. "Speicherplatzverbrauch innerhalb einer Woche um 5GB gestiegen")
|
||||||
- Selbst-Test
|
- Selbst-Test
|
||||||
- Benachrichtigungs-Kanäle:
|
- Benachrichtigungs-Kanäle:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue