InfraGuard

Traffic (Network I/O)

Surfaces per-server inbound/outbound byte and packet throughput from server_traffic as ECharts line charts — data the legacy console collected but never showed.

Overview — what it does

Infrastructure ▸ Connectivity & Traffic ▸ Traffic (/infra/traffic/net) is a read-only console that plots each server's network I/O throughput (inbound/outbound bytes and packets) as one ECharts line chart per server card.

The source is the legacy server_traffic table (≈1.6M rows, legacy_glory connection), filled by the legacy collector check_tx.js. That table accumulates per-window delta bytes and packets for each server × direction (inbound/outbound), but the old stats-design UI only ever showed server_status's traffic-out (a single outbound-packet delta). This screen is the first to surface the full in/out × bytes/packets dataset.

The three sibling screens (Ports, IPs, Traffic) share the same TrafficController and SessionQueryService, but only the Traffic tab reads the server_traffic throughput time series rather than the session snapshot (traffic_session_ct). That is why it uses a range (1h/6h/24h) window instead of the timer (1/5/60 min) used by the other two.

When to use

Layout

Hero (top bar)

Element Description
Metric toggle bytes | packets — recolors the same data on a byte/packet scale (no server round-trip)
Range toggle 1h (60) | 6h (360) | 24h (1440) — display window in minutes. Selection persists to localStorage
Stamp Latest window time (server_traffic MAX + display-timezone shift)
Refresh Immediate re-fetch (independent of the 30s auto-poll)
Fullscreen Hides top nav and enlarges the card grid (ESC to exit)

KPI strip (flow: in · out · packets · ratio → hotspot → freshness)

KPI Meaning
Total in Sum of each server's latest-point inbound bytes
Total out Sum of each server's latest-point outbound bytes
Total packets Sum of each server's last (in+out) packets · unit /window (not cumulative)
In:out out ÷ in (1 decimal) shown as 1 : x. — when in is 0
Top Server with the largest latest outbound bytes (hotspot)
Active servers Count of servers whose last point falls within 15 min of the window end / total. Warns (yellow) when below total

Scale color legend + Y-axis scale

Line/area color encodes the magnitude of the value (ECharts visualMap piecewise). When a value crosses a threshold the color changes, so you feel the scale through color.

tone bytes packets
info < 1MB < 1K
good 1–10MB 1–10K
warn 10–100MB 10–100K
crit > 100MB > 100K

Server traffic cards

Each card = one server. The header shows the hostname plus current in/out bytes; the body is a 200px <metric-chart> (ECharts, dynamic-import) line chart.

How to use

  1. Pick a range — 1h to chase spikes, 24h for daily patterns.
  2. Switch metric — bytes for bandwidth load, packets for connection/PPS character.
  3. Log axis — for servers with a large in/out disparity (web nodes where out ≫ in), log keeps both curves visible.
  4. Reorder cards — drag servers of interest to the top (saved in the browser).
  5. Chase a hotspot — when you spot the KPI Top server or a crit (red) curve, jump to Port Connections / IP Connections to investigate which IP/port drove it.

The tooltip shows an HH:MM header plus each series value (in/out). Even on narrow cards, time-axis labels auto-hide to avoid overlap (hideOverlap).

Data sources

server_traffic (legacy_glory · read-only)

Column Purpose
server_name, server_index Server identity
time_window_start Collection window start (~300s = 5 min apart)
direction inbound | outbound
delta_bytes_count Byte delta for this window
delta_packet_count Packet delta for this window

The source query (TrafficRepository::serverTraffic) uses parameter binding to scan only a tight window (no hardcoding, no string interpolation):

SELECT server_name, server_index, time_window_start, direction,
       delta_packet_count, delta_bytes_count
FROM   server_traffic
WHERE  time_window_start >= :since   -- (latest window) − range
ORDER  BY time_window_start
LIMIT  6000;

Anchor = MAX(time_window_start) (indexed MAX → cheap). since = anchor − range minutes.

Minute-bucket normalization (sawtooth fix)

The check_tx.js collector stamps inbound and outbound with separate new Date() calls inside its loop, so within the same 5-minute cycle the time_window_start values differ by 1–2 seconds (e.g. :02 in / :03 out). Grouping by exact timestamp catches only one of in/out at each instant, leaving the other at 0 — producing a sawtooth chart.

Fix: SessionQueryService::reshapeNet rounds timestamps into a minute bucket (round(ts/60)*60) so in/out merge into a single point. The window interval (300s) is far larger than the bucket (60s), so adjacent windows never collide.

Display-timezone shift

Because the legacy DB store time can differ from display time (observed ~9h skew), values are shifted by OpsPolicy::trafficTzOffsetSec() for display only (stamp, time axis, series timestamps). The SQL boundaries (min/max) are NOT shifted — the query uses raw legacy time.

Cache · polling

Access

Troubleshooting & FAQ

Q. I only see "no traffic samples". It means server_traffic has no recent window. Check that the check_tx.js collector is running and the legacy_glory connection is valid. When latestTrafficWindow() (MAX) is null, cards are empty and KPIs read 0.

Q. A server only draws a short stub on the left. This is by design. The time axis is pinned to a shared window, so a collection-lagged server is drawn honestly up to its last observation as a left-hand stub. It is also counted as inactive in the Active servers KPI (last point falls outside 15 min of the window end).

Q. One direction's curve looks like a sawtooth. Minute-bucket normalization fixes most cases, but if the collection windows themselves are irregular, some residual sawtooth may remain. Switching to the log axis smooths it.

Q. Are the values cumulative? No. delta_* = increment per window (~5 min). That is why the Total packets KPI is labeled /window. These are not cumulative counters.

Q. The times are off by several hours. The display timezone is corrected via OpsPolicy's traffic_tz_offset setting (see Operations Policy).

Related

Network I/O over time
Network I/O over time