File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change 16
16
package sysfs
17
17
18
18
import (
19
+ "errors"
19
20
"os"
20
21
"path/filepath"
21
22
"strings"
23
+ "syscall"
22
24
23
25
"github.com/prometheus/procfs/internal/util"
24
26
)
@@ -39,20 +41,20 @@ type ClassThermalZoneStats struct {
39
41
func (fs FS ) ClassThermalZoneStats () ([]ClassThermalZoneStats , error ) {
40
42
zones , err := filepath .Glob (fs .sys .Path ("class/thermal/thermal_zone[0-9]*" ))
41
43
if err != nil {
42
- return [] ClassThermalZoneStats {} , err
44
+ return nil , err
43
45
}
44
46
45
- var zoneStats = ClassThermalZoneStats {}
46
- stats := make ([]ClassThermalZoneStats , len (zones ))
47
- for i , zone := range zones {
48
- zoneName := strings .TrimPrefix (filepath .Base (zone ), "thermal_zone" )
49
-
50
- zoneStats , err = parseClassThermalZone (zone )
47
+ stats := make ([]ClassThermalZoneStats , 0 , len (zones ))
48
+ for _ , zone := range zones {
49
+ zoneStats , err := parseClassThermalZone (zone )
51
50
if err != nil {
52
- return []ClassThermalZoneStats {}, err
51
+ if errors .Is (err , syscall .ENODATA ) {
52
+ continue
53
+ }
54
+ return nil , err
53
55
}
54
- zoneStats .Name = zoneName
55
- stats [ i ] = zoneStats
56
+ zoneStats .Name = strings . TrimPrefix ( filepath . Base ( zone ), "thermal_zone" )
57
+ stats = append ( stats , zoneStats )
56
58
}
57
59
return stats , nil
58
60
}
You can’t perform that action at this time.
0 commit comments