diff --git a/unifi_respondd/unifi_client.py b/unifi_respondd/unifi_client.py index 143a874..1626ed0 100644 --- a/unifi_respondd/unifi_client.py +++ b/unifi_respondd/unifi_client.py @@ -44,6 +44,12 @@ class Accesspoint: client_count: int client_count24: int client_count5: int + channel5: int + rx_bytes5: bytes + tx_bytes5: bytes + channel24: int + rx_bytes24: bytes + tx_bytes24: bytes latitude: float longitude: float model: str @@ -85,6 +91,23 @@ def get_client_count_for_ap(ap_mac, clients, cfg): client24_count += 1 return client24_count + client5_count, client24_count, client5_count +def get_ap_channel_usage(ssids, cfg): + """This function returns the channels used for the Freifunk SSIDs""" + for ssid in ssids: + if re.search(cfg.ssid_regex, ssid.get("essid", "")): + channel = ssid.get("channel", 0) + rx_bytes = ssid.get("rx_bytes", 0) + tx_bytes = ssid.get("tx_bytes", 0) + if channel > 14: + channel5 = channel + rx_bytes5 = rx_bytes + tx_bytes5 = tx_bytes + else: + channel24 = channel + rx_bytes24 = tx_bytes + tx_bytes24 = tx_bytes + + return channel5, rx_bytes5, tx_bytes5, channel24, rx_bytes24, tx_bytes24 def get_location_by_address(address, app): """This function returns latitude and longitude of a given address.""" @@ -162,6 +185,16 @@ def get_infos(): client_count24, client_count5, ) = get_client_count_for_ap(ap.get("mac", None), clients, cfg) + + ( + channel5, + rx_bytes5, + tx_bytes5, + channel24, + rx_bytes24, + tx_bytes24, + ) = get_ap_channel_usage(ssids, cfg) + lat, lon = 0, 0 neighbour_macs = [] if ap.get("snmp_location", None) is not None: @@ -203,6 +236,12 @@ def get_infos(): client_count=client_count, client_count24=client_count24, client_count5=client_count5, + channel5=channel5, + rx_bytes5=rx_bytes5, + tx_bytes5=tx_bytes5, + channel24=channel24, + rx_bytes24=rx_bytes24, + tx_bytes24=tx_bytes24, latitude=float(lat), longitude=float(lon), model=ap.get("model", None),