{# plugins/unifi/templates/unifi/dpi.html #} {% if not snapshot %}

No DPI data yet. DPI must be enabled on the UniFi controller.

{% else %}
{# Category breakdown #} {% if categories %}
Traffic by Category {{ snapshot.scraped_at.strftime("%H:%M") }}
{% set total_bytes = categories | sum(attribute='rx_bytes') + categories | sum(attribute='tx_bytes') %} {% for cat in categories[:20] %} {% set bytes = cat.rx_bytes + cat.tx_bytes %} {% set pct = (bytes / total_bytes * 100) if total_bytes else 0 %} {% endfor %}
{{ cat.cat_name or cat.cat_id }} {% if bytes >= 1073741824 %}{{ "%.1f"|format(bytes / 1073741824) }} GB {% elif bytes >= 1048576 %}{{ "%.1f"|format(bytes / 1048576) }} MB {% elif bytes >= 1024 %}{{ "%.0f"|format(bytes / 1024) }} KB {% else %}{{ bytes }} B{% endif %}
{% endif %} {# Top clients by DPI #} {% if top_clients %}
Top Clients by Traffic
{% for c in top_clients %} {% endfor %}
{{ c.hostname or c.mac }} {{ c.mac }} {% set bytes = c.bytes %} {% if bytes >= 1073741824 %}{{ "%.1f"|format(bytes / 1073741824) }} GB {% elif bytes >= 1048576 %}{{ "%.1f"|format(bytes / 1048576) }} MB {% elif bytes >= 1024 %}{{ "%.0f"|format(bytes / 1024) }} KB {% else %}{{ bytes }} B{% endif %}
{% endif %}
{% endif %}