Peacock — RGB System Monitor #
Sources/peacock · Rust · Airgoo AG-DRGB08 (channel A4, 24 LEDs across 3 fans)
0. What you see at a glance #
Every LED always shows the SAME hue for the same metric, spread uniformly across all three fans. A glance reads type from color and amount from how many LEDs of that color are lit. A glance at brightness/pulse gives urgency.
- Color (hue) = which subsystem (the "type" of load)
- Quantity = how many LEDs of that color are lit at once (the "how much")
- Brightness = intensity / severity (dim → white-hot as it approaches max)
- Pulse length = event rate (short fast pulses = frantic, small slow pulses = calm)
Over time the human learns: "lots of magenta lit = CPU pinned," "cyan racing around = GPU crunching," "green strobing = network storm," "amber flickering = disk thrashing."
1. Neo-Tokyo palette #
Deep indigo idle base so the case reads "off but alive," four neon hues, each with a hot-shift endpoint when a subsystem saturates.
| Metric | Role | Base hue | Hot/overload shift |
|---|---|---|---|
| CPU | compute | #FF2E97 magenta |
→ #FF1744 crimson at >90% |
| GPU | graphics/ML | #00E5FF cyan |
→ #B2F5FF white-cyan at >90% |
| NET | network | #00FF9C neon green |
→ #7CFF00 acid on bursts |
| DISK | storage I/O | #FF9E00 amber |
→ #FFD23F molten on burst |
| idle | floor | #14002E indigo (≈2% brightness) |
— |
All hues are user-overridable; hue is stored as HSV so the "hue itself" is a single tunable number (0-360) per metric, with saturation/value as sub-tunables.
2. Spatial mapping: 24 LEDs, 3 fans, 4 metrics #
Map each LED to a metric by metric = led_index % 4. With 24 LEDs that gives
each metric a lane of 6 LEDs, interleaved so every fan displays all four
colors (each 8-LED fan = 2 of each hue). Benefit: no matter where the case is,
one fan always shows the whole system state, and aggregate brightness is easy to
read across the cluster.
fan1: C G N D C G N D
fan2: C G N D C G N D
fan3: C G N D C G N D C=CPU G=GPU N=NET D=DISK
The lane is ordered so the "fill direction" runs fan1 → fan2 → fan3. Increasing load on one metric lights LEDs left-to-right across the fans, so magnitude has a physical sweep a person can track out of the corner of their eye.
3. The four tunable variables (per metric, in config) #
[cpu] hue = 330 # degrees; saturation/value below
sat = 1.0
base_brightness = 0.35 # global multiplier
min_pulse_ms = 120 # fastest pulse (high activity)
max_pulse_ms = 1400 # slowest pulse (idle)
lane_len = 6 # max LEDs this metric can light
saturate_at = 0.90 # where hot-shift + alarm pulse kicks in
Mapping, per metric m, from smoothed activity a ∈ [0,1] and event-rate r:
quantity_m = 1 + round( a * (lane_len_m - 1) ) # 1 .. lane_len
brightness_m = base * (floor + (1-floor) * a^0.7) # dim at low, near 1 at max
pulse_len_m = max_pulse - (max_pulse-min_pulse) * r_norm # frantic rate => short
hue_m = (saturated? hot_hue : base_hue) # shift only past threshold
a = load fraction (CPU%, GPU util%, disk busy%, net throughput normalized).
r_norm = rate of change / event rate normalized (packets/s, IOPS, context
swaps) — drives how fast the chosen LEDs breathe.
4. Per-metric feel (so the four never blur together) #
- CPU (magenta): quantity = load, steady breathing pulse. Sustained high load → lane fills + brightens + hue creeps toward crimson = "compute pinned."
- GPU (cyan): quantity = utilization; a short cyan "sweep" (one bright LED running the lane) when util is high but steady = inference/render crunching.
- NET (green): quantity = throughput tier; pulse length = packet rate, so a download is a fast flicker while a big sustained transfer is a bright steady green. Bursts strobe acid.
- DISK (amber): quantity = queue/busy; each I/O burst triggers a quick amber pulse whose length ∝ transfer size. Thrash = rapid repeated amber flicker.
5. Combined render model (all four, at once) #
Fixed index assignment means a given LED belongs to exactly one metric, so there is no color conflict — all four are shown simultaneously and continuously:
- Every frame (~30 fps), for each metric compute
a,r, then the lit set = the firstquantity_mLEDs in that metric's lane (ordered along the chain). - Apply that metric's pulse envelope (breathing between
brightness*0.3andbrightness) usingpulse_len_m. - Unlit LEDs in a lane fall to the indigo idle floor.
- Overload alarm: if
a > saturate_at, that metric's lane blinks to its hot hue and its pulse bottoms tomin_pulse— an unmistakable "saturated" tell.
The loop is additive in human perception: because each hue owns its own LEDs, the brain integrates "how much of each color is glowing" directly as load per subsystem, and the global brightness of the whole cluster as total system stress.
6. Signal smoothing (so it reads, not jitters) #
- 250 ms sampling, 1 s exponential moving average for
a(quantity/brightness). - Separate fast EMA (≈150 ms) for
r(pulse rate) so bursts snap fast. - Peak-hold with decay on NET/DISK so short spikes are visible for ~1 s.
7. Metrics acquisition #
| Metric | Source |
|---|---|
| CPU | /proc/stat delta (aggregate %busy) — crate sysinfo |
| GPU | NVML via nvml-wrapper (util + mem), fallback nvidia-smi |
| NET | /proc/net/dev byte delta across active ifaces (eth+wl) |
| DISK | /proc/diskstats sectors/s + I/O-time busy% on real block devs (skip loop/ram) |
8. Hardware I/O #
Reuse the proven direct DRGB-V4 path (OpenRGB CLI doesn't work for this board).
Rust talks /dev/hidraw8 directly:
- crate
hidapi(or rawlibcwrite() on the hidraw node, mirroring the Python driver that already works), - keepalive thread: 65-byte packet, byte[1]=
0x65, every 400 ms (mandatory — board reverts to dark onboard pattern otherwise), - write path: 1025-byte report, 72-byte per-zone header + RGB payload; all 8 channels must carry data, A4 = the 24-LED strip, other channels padded with 1 black LED (board drops frames where any channel has zero LEDs).
Keepalive and animation run as one process; a --oneshot mode for scripting.
9. Architecture (crate layout) #
Sources/peacock/
Cargo.toml
src/
main.rs # CLI (--config, --oneshot, --test, --list), event loop
config.rs # TOML config -> per-metric tunables + palette
metrics.rs # poller: cpu/gpu/net/disk -> (activity, rate) each 250ms
gpu.rs # NVML wrapper + nvidia-smi fallback
render.rs # activity+rate -> LED frames (quantity/pulse/brightness/hue)
device.rs # DRGB-V4 HID writer + keepalive thread
palette.rs # neo-tokyo hues, HSV->RGB, hot-shift
peacock.toml # default config
10. Demo / acceptance #
peacock --test sweep→ one LED walks the chain (already proven working).peacock --test hue→ cycle each metric lane to confirm order + colors.peacock→ live monitor. Load generators (stress-ng --cpu,fio,iperf, GPU bench) should visibly fill the corresponding colored lane.
11. Milestones #
device.rs— port the working Python DRGB-V4 writer + keepalive to Rust.palette.rs+render.rs— static palette + fixed index map, lit-lane demo.metrics.rs(cpu/net/disk via /proc) +gpu.rs(NVML).- Wire tunables, smoothing, pulse/brightness/quantity mapping.
- Overload hot-shift + alarm,
--testmodes, config file, systemd user unit.
12. Open decisions (pick during build) #
- Interleave
i%4(every fan shows all colors) vs contiguous 6-LED blocks (per-fan grouping). Spec defaults toi%4; both configurable. - Whether brightness should also encode load or stay a pure user dimmer.
- NET/DISK normalization ceilings (link speed, disk peak MB/s) — auto-calibrate from observed max, or fixed in config.