mirror of
https://github.com/outscale/zabbix-super-vision.git
synced 2025-08-05 11:21:15 +02:00
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:
27
utils/hostgroups.py
Normal file
27
utils/hostgroups.py
Normal 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
|
Reference in New Issue
Block a user