{% extends "base.html" %} {% block title %}客户端 {{ client }} - Squid Manager{% endblock %} {% block head %} {% endblock %} {% block content %} {# P2-4: per-client 24h trend. When the client has no rows in the parsed log, render an empty-state card instead of empty charts so the page is informative (and so we don't ship a 0-axis Chart.js graph). #} {% if not has_data %}
🔍

未找到该客户端的日志

已加载的日志范围内没有来自 {{ client }} 的请求记录。

可能原因: 客户端拼写错误、尚未产生流量、或日志已被归档。

去日志查询 🔄 立即同步日志

{% else %}
总请求数
{{ trend.total_requests | thousands }}
该客户端的累计请求
总流量
{{ format_bytes(trend.total_bytes) }}
原始字节数 {{ trend.total_bytes | thousands }}
平均请求大小
{{ format_bytes(trend.avg_size_bytes) }}
{{ '%.0f' % trend.avg_size_bytes }} 字节/请求
首次出现
{% if trend.time_start %} {{ trend.time_start.strftime('%m-%d %H:%M') }} {% else %} - {% endif %}
{% if trend.time_start %}{{ trend.time_start.strftime('%Y-%m-%d %H:%M:%S UTC') }}{% else %}-{% endif %}
最后出现
{% if trend.time_end %} {{ trend.time_end.strftime('%m-%d %H:%M') }} {% else %} - {% endif %}
{% if trend.time_end %}{{ trend.time_end.strftime('%Y-%m-%d %H:%M:%S UTC') }}{% else %}-{% endif %}
Top 主机数
{{ trend.top_hosts | length }}
访问过的目标主机

📈 24h 趋势 (按 UTC 小时聚合)

横轴 = UTC 小时 (00-23) · 左轴 = 请求数 · 右轴 = 流量 (MB)。 与仪表盘的 24h 折线结构一致,方便横向对比整体流量。

🌍 Top 目标主机 (按请求数)

{% if trend.top_hosts %} {% for h in trend.top_hosts %} {% endfor %}
#目标主机请求数流量
{{ loop.index }} {{ h.host }} {{ h.count | thousands }} {{ format_bytes(h.bytes) }}
{% else %}

无目标主机数据。

{% endif %}

🔗 Top URL (访问最多的资源)

{% if trend.top_urls %} {% for u in trend.top_urls %} {% endfor %}
#URL访问次数
{{ loop.index }} {{ u.url }} {{ u.count | thousands }}
{% else %}

无 URL 数据。

{% endif %}

📜 最近 50 条请求样本

{% if trend.samples %}
{% for e in trend.samples %} {% endfor %}
时间 结果码 HTTP 方法 大小 耗时 URL 层级
{% if e.timestamp %} {{ e.timestamp.strftime('%Y-%m-%d %H:%M:%S') }} {% else %} {{ e.time }} {% endif %} {{ e.result_code }} {{ e.http_code or '-' }} {{ e.method }} {{ format_bytes(e.size) }} {{ format_duration(e.elapsed_ms) }} {{ e.url }} {{ e.hier_code }}
{% else %}

无样本数据。

{% endif %}

🚫 操作

封禁功能将由 P3-2 提供:写入 squid ACL + 重载配置 + 持久化黑名单。
{% endif %} {% endblock %} {% block scripts %} {# Drive the 24h hourly chart. Same dual-axis pattern as the dashboard so an operator can mentally diff a single client's curve against the global 24h envelope without learning a new visualisation. #} {% endblock %}