How smare/rpi_server_stats works
Project Type and Purpose
• This is an open-source utility for Raspberry Pi devices that collects OS statistics (CPU, memory, disk, network, etc.) and renders them on an attached ST7789 display.
• It provides two parallel setups: one for Raspberry Pi 5+ (run_rpi5_stats_ST7789.py + prerequisites-run_rpi5_stats_ST7789.sh + doc/rpi5/) and one for Raspberry Pi 4 and older (run_rpi_stats_ST7789.py + prerequisites-run_rpi_stats_ST7789.sh + doc/rpi/).
File Structure
• Top level:
• README.md – project overview
• doc/rpi & doc/rpi5 – hardware-specific setup instructions
• Shell scripts (prerequisites-*.sh) – install dependencies (Python libraries, SPI drivers, etc.)
• Python scripts (run_*.py) – collect stats & drive the ST7789 display
• No database or web server – it’s a single‐device, script‐driven tool.
• Uses hardware SPI (or bit-banged GPIO) to drive the ST7789 display.
README for Additional Insights
• Clarifies supported Pi models and links to hardware‐specific docs.
• Implies use of standard system‐metric libraries (e.g., psutil in Python) and low‐level SPI display drivers.
Main Components to Model
a. Hardware Layer
• Raspberry Pi board (BCM SoC + Linux OS)
• ST7789 display module (connected over SPI/GPIO)
b. Software Layer
• Prerequisite installer script (shell script)
• Python stats-collector & display renderer
• Underlying libraries:
• OS stats library (e.g., psutil)
• SPI/display driver (e.g., luma.lcd or direct spidev)
c. Documentation
• doc/rpi and doc/rpi5 as user-facing setup guides
Relationships and Data Flows
• Data flow:
1. Shell script installs Python, pip packages, SPI kernel modules.
2. Python script reads OS metrics via psutil.
3. Script formats metrics into text/graphics.
4. Script sends pixel/command frames over SPI to ST7789.
5. Module renders the frame.
• OS kernel → Python stats library
• Python application → SPI driver → ST7789 hardware
• Shell script → OS package manager
Architectural Patterns and Principles
• Single‐process application pattern (no multi-service or microservices).
• Clear separation:
• Setup phase (shell script) vs. runtime phase (Python script).
• Metric-collection vs. rendering logic.
• Extensibility point: adding support for new display types by swapping the rendering driver.