From 655bfc95caecdcfd58dd35401fd37da50de49ddd Mon Sep 17 00:00:00 2001 From: Henry Dollman Date: Mon, 4 Nov 2024 20:52:27 -0500 Subject: [PATCH] add ability to specify partition for extra disk using folder name --- beszel/internal/agent/disk.go | 17 +++++++++++++---- readme.md | 6 +++--- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/beszel/internal/agent/disk.go b/beszel/internal/agent/disk.go index 9df83be..5fb0013 100644 --- a/beszel/internal/agent/disk.go +++ b/beszel/internal/agent/disk.go @@ -41,11 +41,20 @@ func (a *Agent) initializeDiskInfo() { if _, exists := a.fsStats[key]; !exists { if root { slog.Info("Detected root device", "name", key) - // check if root device is in /proc/diskstats, use fallback if not + // Check if root device is in /proc/diskstats, use fallback if not if _, exists := diskIoCounters[key]; !exists { - slog.Warn("Device not found in diskstats", "name", key) key = findFallbackIoDevice(filesystem, diskIoCounters, a.fsStats) - slog.Info("Using I/O fallback", "name", key) + slog.Info("Using I/O fallback", "device", device, "mountpoint", mountpoint, "fallback", key) + } + } else { + // Check if non-root has diskstats and fall back to folder name if not + // Scenario: device is encrypted and named luks-2bcb02be-999d-4417-8d18-5c61e660fb6e - not in /proc/diskstats. + // However, the device can be specified by mounting folder from luks device at /extra-filesystems/sda1 + if _, exists := diskIoCounters[key]; !exists { + efBase := filepath.Base(mountpoint) + if _, exists := diskIoCounters[efBase]; exists { + key = efBase + } } } a.fsStats[key] = &system.FsStats{Root: root, Mountpoint: mountpoint} @@ -114,7 +123,7 @@ func (a *Agent) initializeDiskInfo() { mountpoint := filepath.Join(efPath, folder.Name()) slog.Debug("/extra-filesystems", "mountpoint", mountpoint) if !existingMountpoints[mountpoint] { - a.fsStats[folder.Name()] = &system.FsStats{Mountpoint: mountpoint} + addFsStat(folder.Name(), mountpoint, false) } } } diff --git a/readme.md b/readme.md index 323b07f..ca5a291 100644 --- a/readme.md +++ b/readme.md @@ -61,7 +61,7 @@ If you don't need network stats, remove that line from the compose file and map ### Binary > [!TIP] -> If using Linux, see [guides/systemd.md](/supplemental/guides/systemd.md) for a script to install the hub or agent as a system service. The agent installer will be built into the web UI in the future. +> If using Linux, see [guides/systemd.md](/supplemental/guides/systemd.md) for a script to install the hub or agent as a system service. This is also built into the web UI. Download and run the latest binaries from the [releases page](https://github.com/henrygd/beszel/releases) or use the commands below. @@ -168,8 +168,8 @@ Mount a folder from the target filesystem in the container's `/extra-filesystems ```yaml volumes: - - /mnt/disk1/.beszel:/extra-filesystems/disk1:ro - - /dev/mmcblk0/.beszel:/extra-filesystems/sd-card:ro + - /mnt/disk1/.beszel:/extra-filesystems/sdb1:ro + - /dev/mmcblk0/.beszel:/extra-filesystems/mmcblk0:ro ``` ### Binary