HIRO GEAR
自作開発 RaspberryPi Rust

Création d'un tableau de bord ultra-léger avec Raspberry Pi 5 : une architecture à charge nulle en temps normal grâce à Rust

Création d'un tableau de bord ultra-léger avec Raspberry Pi 5 : une architecture à charge nulle en temps normal grâce à Rust

The Raspberry Pi 5 (Server #70) running at home hosts numerous containers essential for daily life, including WordPress, Nextcloud, PhotoPrism, and AdGuard Home.

When setting up a system monitoring dashboard on a server that runs constantly, the most concerning issue was the counterproductive situation where “the monitoring process itself consumes CPU and disk I/O continuously.”

Therefore, I decided to build an ultra-energy-efficient, on-demand monitoring dashboard in Rust that “only moves when viewed in a browser and remains completely silent otherwise.”

The Core of the Design: Zero Load During Normal Operation

The following three points were rigorously implemented in this new dashboard, “Gonta Command Center”:

  1. Full Inclusion into a Single Binary
    • All HTML/CSS/JS are baked directly into the Rust binary using include_str!, eliminating even physical disk reads when displaying the screen.
  2. On-Demand Communication via Server-Sent Events (SSE)
    • No background daemon runs periodically; data is pulled from kernel virtual memory (/proc, /sys) at a 3-second interval only when the browser connects.
  3. Automatic Suspension upon Mobile Screen Dimming
    • The browser’s visibilitychange event is captured to sever the SSE connection instantly when a tab is hidden or a mobile device enters sleep mode.

[!NOTE] Metrics for LVM SSD cache hit rates (dm-cache) and disk capacity, which are monitored targets, are also fetched on-demand only during initial load or button presses, thoroughly eliminating unnecessary command execution overhead.

Results: A Mere 2.6MB Binary

The built binary size is a mere 2.6MB. Memory footprint stays within a few MBs, achieving a CPU usage rate of 0.0% during idle states.

Next, I will proceed with integrating this dashboard to send Wake-on-LAN signals via an external smartphone, enabling the main development PC to be started or stopped with a single finger tap.