diff --git a/internal/glance/cli.go b/internal/glance/cli.go index 34c8dff..47bb289 100644 --- a/internal/glance/cli.go +++ b/internal/glance/cli.go @@ -96,15 +96,19 @@ func parseCliOptions() (*cliOptions, error) { func cliSensorsPrint() int { tempSensors, err := sensors.SensorsTemperatures() if err != nil { - fmt.Printf("Errors encountered while retrieving list of sensors:\n %v\n", err) if warns, ok := err.(*sensors.Warnings); ok { + fmt.Printf("Could not retrieve information for some sensors (%v):\n", err) for _, w := range warns.List { fmt.Printf(" - %v\n", w) } + fmt.Println() + } else { + fmt.Printf("Failed to retrieve sensor information: %v\n", err) + return 1 } } - if tempSensors == nil || len(tempSensors) == 0 { + if len(tempSensors) == 0 { fmt.Println("No sensors found") return 0 } diff --git a/pkg/sysinfo/sysinfo.go b/pkg/sysinfo/sysinfo.go index 9a35710..ed20318 100644 --- a/pkg/sysinfo/sysinfo.go +++ b/pkg/sysinfo/sysinfo.go @@ -201,11 +201,12 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) { // currently disabled on Windows because it requires elevated privilidges, otherwise // keeps returning a single sensor with key "ACPI\\ThermalZone\\TZ00_0" which // doesn't seem to be the CPU sensor or correspond to anything useful when - // compared against the temperatures Libre Hardware Monitor reports - // also disabled on openbsd because it's not implemented by go-psutil - if runtime.GOOS != "windows" && runtime.GOOS != "openbsd" { + // compared against the temperatures Libre Hardware Monitor reports. + // Also disabled on the bsd's because it's not implemented by go-psutil for them + if runtime.GOOS != "windows" && runtime.GOOS != "openbsd" && runtime.GOOS != "netbsd" && runtime.GOOS != "freebsd" { sensorReadings, err := sensors.SensorsTemperatures() - if sensorReadings != nil && len(sensorReadings) > 0 { + _, errIsWarning := err.(*sensors.Warnings) + if err == nil || errIsWarning { if req.CPUTempSensor != "" { for i := range sensorReadings { if sensorReadings[i].SensorKey == req.CPUTempSensor {