Compare commits
6 Commits
Author | SHA1 | Date |
---|---|---|
|
2d9f8942b0 | |
|
605d086670 | |
|
6a03ac0e77 | |
|
9ac5c80f73 | |
|
876b3901a5 | |
|
09a890a04a |
2
main.py
2
main.py
|
@ -51,7 +51,7 @@ async def dashboard():
|
|||
for new_alert in new_alerts_id:
|
||||
message = (
|
||||
icon_dict[active_alerts[new_alert]["severity"]]
|
||||
+ f"{active_alerts[new_alert]['host']}\n"
|
||||
+ f" {active_alerts[new_alert]['host']}\n"
|
||||
+ f"{active_alerts[new_alert]['name']}"
|
||||
)
|
||||
msg_id = await send_message(message=message, event_id=new_alert)
|
||||
|
|
|
@ -10,8 +10,8 @@ from datetime import datetime, timedelta
|
|||
|
||||
|
||||
def get_active_problems() -> dict:
|
||||
api = ZabbixAPI(url=conf.zabbix.url, token=conf.zabbix.token)
|
||||
try:
|
||||
api = ZabbixAPI(url=conf.zabbix.url, token=conf.zabbix.token)
|
||||
problems = api.problem.get(
|
||||
output=[
|
||||
"eventid",
|
||||
|
@ -28,7 +28,7 @@ def get_active_problems() -> dict:
|
|||
event_ids.append(problem["eventid"])
|
||||
|
||||
events = api.event.get(
|
||||
selectHosts=["host"],
|
||||
selectHosts=["name"],
|
||||
eventids=event_ids,
|
||||
output=[
|
||||
"eventid",
|
||||
|
@ -38,7 +38,7 @@ def get_active_problems() -> dict:
|
|||
)
|
||||
events_dict = {"event_ids": []}
|
||||
for event in events:
|
||||
event["host"] = event.pop("hosts", None)[0]["host"]
|
||||
event["host"] = event.pop("hosts", None)[0]["name"]
|
||||
events_dict[event["eventid"]] = event
|
||||
events_dict["event_ids"].append(event["eventid"])
|
||||
return events_dict
|
||||
|
|
Loading…
Reference in New Issue