pi_dashboard.system_metrics_handler

System metrics collection handler for Pi Dashboard.

This module provides functions to collect system metrics from the host system, even when running inside a Docker container. It uses psutil and direct file reading from mounted host directories.

Functions

get_host_path(relative_path)

Get the path to a host system file from within Docker container.

get_host_root()

Get the host root path for metrics collection.

get_hostname()

Get the system hostname, attempting to read from host filesystem if in Docker.

get_system_info()

Get system information using platform module.

get_system_metrics()

Get current system metrics.

read_cpu_temperature()

Read CPU temperature from thermal zone.

read_uptime()

Read system uptime from /proc/uptime.

pi_dashboard.system_metrics_handler.get_host_root()[source]

Get the host root path for metrics collection.

Return str:

The host root path

Return type:

str

pi_dashboard.system_metrics_handler.get_host_path(relative_path)[source]

Get the path to a host system file from within Docker container.

If running in Docker with host mounts, accesses files from /host/* paths. Otherwise, accesses system files directly.

Parameters:

relative_path (str) – The relative path (e.g., “proc/uptime”)

Return Path:

The full path to the file

Return type:

Path

pi_dashboard.system_metrics_handler.get_hostname()[source]

Get the system hostname, attempting to read from host filesystem if in Docker.

Return str:

The system hostname

Return type:

str

pi_dashboard.system_metrics_handler.read_cpu_temperature()[source]

Read CPU temperature from thermal zone.

Return float:

CPU temperature in Celsius, or 0.0 if unavailable

Return type:

float

pi_dashboard.system_metrics_handler.read_uptime()[source]

Read system uptime from /proc/uptime.

Return int:

System uptime in seconds, or 0 if unavailable

Return type:

int

pi_dashboard.system_metrics_handler.get_system_info()[source]

Get system information using platform module.

When running in Docker, reads hostname from host filesystem.

Return SystemInfo:

System information data

Return type:

SystemInfo

pi_dashboard.system_metrics_handler.get_system_metrics()[source]

Get current system metrics.

Collects CPU, memory, disk usage, uptime, and temperature. When running in Docker with host mounts, reads host system metrics.

Return SystemMetrics:

System metrics data

Return type:

SystemMetrics