mirror of
https://github.com/glanceapp/glance.git
synced 2025-06-21 18:31:24 +02:00
Merge pull request #583 from anxdpanic/sensors
[sensors] allow sensor readings when there are warnings
This commit is contained in:
commit
44ea98fc41
@ -96,13 +96,16 @@ 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)
|
|
||||||
if warns, ok := err.(*sensors.Warnings); ok {
|
if warns, ok := err.(*sensors.Warnings); ok {
|
||||||
|
fmt.Printf("Could not retrieve information for some sensors (%v):\n", err)
|
||||||
for _, w := range warns.List {
|
for _, w := range warns.List {
|
||||||
fmt.Printf(" - %v\n", w)
|
fmt.Printf(" - %v\n", w)
|
||||||
}
|
}
|
||||||
|
fmt.Println()
|
||||||
|
} else {
|
||||||
|
fmt.Printf("Failed to retrieve sensor information: %v\n", err)
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(tempSensors) == 0 {
|
if len(tempSensors) == 0 {
|
||||||
@ -110,8 +113,9 @@ func cliSensorsPrint() int {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
@ -201,11 +201,12 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) {
|
|||||||
// currently disabled on Windows because it requires elevated privilidges, otherwise
|
// currently disabled on Windows because it requires elevated privilidges, otherwise
|
||||||
// keeps returning a single sensor with key "ACPI\\ThermalZone\\TZ00_0" which
|
// 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
|
// doesn't seem to be the CPU sensor or correspond to anything useful when
|
||||||
// compared against the temperatures Libre Hardware Monitor reports
|
// compared against the temperatures Libre Hardware Monitor reports.
|
||||||
// also disabled on openbsd because it's not implemented by go-psutil
|
// Also disabled on the bsd's because it's not implemented by go-psutil for them
|
||||||
if runtime.GOOS != "windows" && runtime.GOOS != "openbsd" {
|
if runtime.GOOS != "windows" && runtime.GOOS != "openbsd" && runtime.GOOS != "netbsd" && runtime.GOOS != "freebsd" {
|
||||||
sensorReadings, err := sensors.SensorsTemperatures()
|
sensorReadings, err := sensors.SensorsTemperatures()
|
||||||
if err == nil {
|
_, errIsWarning := err.(*sensors.Warnings)
|
||||||
|
if err == nil || errIsWarning {
|
||||||
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