mirror of
https://github.com/JustKato/drive-health.git
synced 2026-03-19 15:09:46 +02:00
Fixed major bug
* Resolved the hwmon not found problem
This commit is contained in:
@@ -44,16 +44,19 @@ type Snapshots struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (h *HardDrive) GetTemperature() int {
|
func (h *HardDrive) GetTemperature() int {
|
||||||
|
|
||||||
|
possiblePaths := []string{
|
||||||
|
"/sys/block/" + h.Name + "/device/hwmon/",
|
||||||
|
"/sys/block/" + h.Name + "/device/",
|
||||||
|
"/sys/block/" + h.Name + "/device/generic/device/",
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, path := range possiblePaths {
|
||||||
// Try HDD/SSD path
|
// Try HDD/SSD path
|
||||||
temp, found := h.getTemperatureFromPath("/sys/block/" + h.Name + "/device/hwmon/")
|
temp, found := h.getTemperatureFromPath(path)
|
||||||
if found {
|
if found {
|
||||||
return temp
|
return temp
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try NVMe path
|
|
||||||
temp, found = h.getTemperatureFromPath("/sys/block/" + h.Name + "/device/")
|
|
||||||
if found {
|
|
||||||
return temp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Printf("[🛑] Failed to get temperature for %s\n", h.Name)
|
fmt.Printf("[🛑] Failed to get temperature for %s\n", h.Name)
|
||||||
|
|||||||
Reference in New Issue
Block a user