mirror of
https://github.com/outscale/zabbix-super-vision.git
synced 2024-11-14 12:25:47 +01:00
f2235d4b45
- 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
28 lines
840 B
Python
28 lines
840 B
Python
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
|