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