From de08a7f970f4b1777055e90f1be6149fcc271a68 Mon Sep 17 00:00:00 2001 From: Daniel Legt Date: Mon, 22 Jan 2024 12:39:31 +0200 Subject: [PATCH] Fixed major bug * Resolved the hwmon not found problem --- lib/hardware/models.go | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/hardware/models.go b/lib/hardware/models.go index 47f091f..cebf906 100644 --- a/lib/hardware/models.go +++ b/lib/hardware/models.go @@ -44,16 +44,19 @@ type Snapshots struct { } func (h *HardDrive) GetTemperature() int { - // Try HDD/SSD path - temp, found := h.getTemperatureFromPath("/sys/block/" + h.Name + "/device/hwmon/") - if found { - return temp + + possiblePaths := []string{ + "/sys/block/" + h.Name + "/device/hwmon/", + "/sys/block/" + h.Name + "/device/", + "/sys/block/" + h.Name + "/device/generic/device/", } - // Try NVMe path - temp, found = h.getTemperatureFromPath("/sys/block/" + h.Name + "/device/") - if found { - return temp + for _, path := range possiblePaths { + // Try HDD/SSD path + temp, found := h.getTemperatureFromPath(path) + if found { + return temp + } } fmt.Printf("[🛑] Failed to get temperature for %s\n", h.Name)