mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 02:18:22 +02:00
[sensors] allow sensor readings when there are warnings
This commit is contained in:
parent
0daa620b11
commit
41e74ba9b5
@ -96,22 +96,22 @@ func parseCliOptions() (*cliOptions, error) {
|
||||
func cliSensorsPrint() int {
|
||||
tempSensors, err := sensors.SensorsTemperatures()
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to retrieve list of sensors: %v\n", err)
|
||||
fmt.Printf("Errors encountered while retrieving list of sensors:\n %v\n", err)
|
||||
if warns, ok := err.(*sensors.Warnings); ok {
|
||||
for _, w := range warns.List {
|
||||
fmt.Printf(" - %v\n", w)
|
||||
}
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
if len(tempSensors) == 0 {
|
||||
if tempSensors == nil || len(tempSensors) == 0 {
|
||||
fmt.Println("No sensors found")
|
||||
return 0
|
||||
}
|
||||
|
||||
fmt.Println("Sensors found:")
|
||||
for _, sensor := range tempSensors {
|
||||
fmt.Printf("%s: %.1f°C\n", sensor.SensorKey, sensor.Temperature)
|
||||
fmt.Printf(" %s: %.1f°C\n", sensor.SensorKey, sensor.Temperature)
|
||||
}
|
||||
|
||||
return 0
|
||||
|
@ -205,7 +205,7 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) {
|
||||
// also disabled on openbsd because it's not implemented by go-psutil
|
||||
if runtime.GOOS != "windows" && runtime.GOOS != "openbsd" {
|
||||
sensorReadings, err := sensors.SensorsTemperatures()
|
||||
if err == nil {
|
||||
if sensorReadings != nil && len(sensorReadings) > 0 {
|
||||
if req.CPUTempSensor != "" {
|
||||
for i := range sensorReadings {
|
||||
if sensorReadings[i].SensorKey == req.CPUTempSensor {
|
||||
|
Loading…
x
Reference in New Issue
Block a user