New supervision

- using fastAPI
- offline/online working
- warning if ZABBIX API is too long
- showing settings
- showing last ack message
- showing procedure
- menu split by SU team
This commit is contained in:
sylvain.chateau
2024-02-05 15:44:27 +01:00
parent f493406b5b
commit f2235d4b45
60 changed files with 10017 additions and 221 deletions

27
utils/hostgroups.py Normal file
View File

@@ -0,0 +1,27 @@
import random
from typing import List
from schemas import HostGroupRequest
from schemas.zabbix_client import ZabbixClient
from settings import settings
def get_hostgroup_color(hostgroup: str):
color = settings.COLOR_TEAM.get(hostgroup)
if color is None:
color = f"#{random.randint(0, 0xFFFFFF):06x};"
settings.COLOR_TEAM[hostgroup] = color
return color
async def get_hostgroups(zabbix_client: ZabbixClient) -> List[str]:
groups = []
for hg in [team for teams in settings.TEAMS.values() for team in teams]:
request = HostGroupRequest(search={"name": hg})
resp = await zabbix_client.call(
request=request.model_dump(), method="hostgroup.get"
)
# Process response
for item in resp["result"]:
groups.append(item["name"])
return groups