fix(health-agent): fix notification param name and type — notificationIDList expects a list of IDs not a dict
This commit is contained in:
parent
a5fc058978
commit
2827b227d5
@ -35,11 +35,7 @@ def find_parent_group(monitor_name, groups, group_map):
|
|||||||
def find_group_notifications(monitor_name, groups, notification_map):
|
def find_group_notifications(monitor_name, groups, notification_map):
|
||||||
for g in groups:
|
for g in groups:
|
||||||
if monitor_name in g.get("children", []):
|
if monitor_name in g.get("children", []):
|
||||||
ids = {}
|
ids = [notification_map[n] for n in g.get("notifications", []) if notification_map.get(n) is not None]
|
||||||
for n in g.get("notifications", []):
|
|
||||||
nid = notification_map.get(n)
|
|
||||||
if nid is not None:
|
|
||||||
ids[str(nid)] = True
|
|
||||||
return ids or None
|
return ids or None
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -119,11 +115,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
raw_name = g["name"]
|
raw_name = g["name"]
|
||||||
formatted_name = f"{project} [{env_name}] {raw_name}"
|
formatted_name = f"{project} [{env_name}] {raw_name}"
|
||||||
|
|
||||||
notif_ids = {}
|
notif_ids = [notification_map[n] for n in g.get("notifications", []) if notification_map.get(n) is not None]
|
||||||
for n in g.get("notifications", []):
|
|
||||||
nid = notification_map.get(n)
|
|
||||||
if nid is not None:
|
|
||||||
notif_ids[str(nid)] = True
|
|
||||||
|
|
||||||
logger.info(f"Processing group: {formatted_name}")
|
logger.info(f"Processing group: {formatted_name}")
|
||||||
if not dry_run:
|
if not dry_run:
|
||||||
@ -131,7 +123,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
logger.info(f"Creating group monitor: {formatted_name}")
|
logger.info(f"Creating group monitor: {formatted_name}")
|
||||||
kwargs = {"type": MonitorType.GROUP, "name": formatted_name}
|
kwargs = {"type": MonitorType.GROUP, "name": formatted_name}
|
||||||
if notif_ids:
|
if notif_ids:
|
||||||
kwargs["notification_id_list"] = notif_ids
|
kwargs["notificationIDList"] = notif_ids
|
||||||
res = api.add_monitor(**kwargs)
|
res = api.add_monitor(**kwargs)
|
||||||
group_map[raw_name] = res['monitorID']
|
group_map[raw_name] = res['monitorID']
|
||||||
else:
|
else:
|
||||||
@ -168,7 +160,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
"parent": parent_group_id
|
"parent": parent_group_id
|
||||||
}
|
}
|
||||||
if notif_ids:
|
if notif_ids:
|
||||||
kwargs["notification_id_list"] = notif_ids
|
kwargs["notificationIDList"] = notif_ids
|
||||||
result = api.add_monitor(**kwargs)
|
result = api.add_monitor(**kwargs)
|
||||||
new_monitor_ids[m_name] = result['monitorID']
|
new_monitor_ids[m_name] = result['monitorID']
|
||||||
else:
|
else:
|
||||||
@ -215,7 +207,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
if parent_group_id is not None:
|
if parent_group_id is not None:
|
||||||
kwargs["parent"] = parent_group_id
|
kwargs["parent"] = parent_group_id
|
||||||
if notif_ids:
|
if notif_ids:
|
||||||
kwargs["notification_id_list"] = notif_ids
|
kwargs["notificationIDList"] = notif_ids
|
||||||
api.add_monitor(**kwargs)
|
api.add_monitor(**kwargs)
|
||||||
logger.info(f"Created HTTP monitor: {m_name}")
|
logger.info(f"Created HTTP monitor: {m_name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -248,7 +240,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
if parent_group_id is not None:
|
if parent_group_id is not None:
|
||||||
kwargs["parent"] = parent_group_id
|
kwargs["parent"] = parent_group_id
|
||||||
if notif_ids:
|
if notif_ids:
|
||||||
kwargs["notification_id_list"] = notif_ids
|
kwargs["notificationIDList"] = notif_ids
|
||||||
api.add_monitor(**kwargs)
|
api.add_monitor(**kwargs)
|
||||||
logger.info(f"Created DNS monitor: {m_name}")
|
logger.info(f"Created DNS monitor: {m_name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -284,7 +276,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
if parent_group_id is not None:
|
if parent_group_id is not None:
|
||||||
kwargs["parent"] = parent_group_id
|
kwargs["parent"] = parent_group_id
|
||||||
if notif_ids:
|
if notif_ids:
|
||||||
kwargs["notification_id_list"] = notif_ids
|
kwargs["notificationIDList"] = notif_ids
|
||||||
api.add_monitor(**kwargs)
|
api.add_monitor(**kwargs)
|
||||||
logger.info(f"Created Ping monitor: {m_name}")
|
logger.info(f"Created Ping monitor: {m_name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -314,7 +306,7 @@ def setup_uptime_kuma(dry_run=False, only=None):
|
|||||||
if parent_group_id is not None:
|
if parent_group_id is not None:
|
||||||
kwargs["parent"] = parent_group_id
|
kwargs["parent"] = parent_group_id
|
||||||
if notif_ids:
|
if notif_ids:
|
||||||
kwargs["notification_id_list"] = notif_ids
|
kwargs["notificationIDList"] = notif_ids
|
||||||
api.add_monitor(**kwargs)
|
api.add_monitor(**kwargs)
|
||||||
logger.info(f"Created Ping monitor: {m_name}")
|
logger.info(f"Created Ping monitor: {m_name}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user