File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed
Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ func parseCliOptions() (*cliOptions, error) {
9696func cliSensorsPrint () int {
9797 tempSensors , err := sensors .SensorsTemperatures ()
9898 if err != nil {
99- fmt .Printf ("Failed to retrieve list of sensors: %v\n " , err )
99+ fmt .Printf ("Errors encountered while retrieving list of sensors:\n %v\n " , err )
100100 if warns , ok := err .(* sensors.Warnings ); ok {
101101 for _ , w := range warns .List {
102102 fmt .Printf (" - %v\n " , w )
@@ -106,13 +106,14 @@ func cliSensorsPrint() int {
106106 return 1
107107 }
108108
109- if len (tempSensors ) == 0 {
109+ if tempSensors == nil || len (tempSensors ) == 0 {
110110 fmt .Println ("No sensors found" )
111111 return 0
112112 }
113113
114+ fmt .Println ("Sensors found:" )
114115 for _ , sensor := range tempSensors {
115- fmt .Printf ("%s: %.1f°C\n " , sensor .SensorKey , sensor .Temperature )
116+ fmt .Printf (" %s: %.1f°C\n " , sensor .SensorKey , sensor .Temperature )
116117 }
117118
118119 return 0
Original file line number Diff line number Diff line change @@ -205,7 +205,7 @@ func Collect(req *SystemInfoRequest) (*SystemInfo, []error) {
205205 // also disabled on openbsd because it's not implemented by go-psutil
206206 if runtime .GOOS != "windows" && runtime .GOOS != "openbsd" {
207207 sensorReadings , err := sensors .SensorsTemperatures ()
208- if err == nil {
208+ if sensorReadings != nil && len ( sensorReadings ) > 0 {
209209 if req .CPUTempSensor != "" {
210210 for i := range sensorReadings {
211211 if sensorReadings [i ].SensorKey == req .CPUTempSensor {
You can’t perform that action at this time.
0 commit comments