Merge branch 'main' of https://github.com/IceWhaleTech/CasaOS
This commit is contained in:
commit
299b20a087
2 changed files with 15 additions and 6 deletions
|
@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Security
|
### Security
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
- [System] Re-instate default zone0 for CPU Temp ([#694](https://github.com/IceWhaleTech/CasaOS/issues/694))
|
||||||
|
|
||||||
## [0.3.8] 2022-11-21
|
## [0.3.8] 2022-11-21
|
||||||
|
|
||||||
|
|
|
@ -319,11 +319,13 @@ func GetCPUThermalZone() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for i := 0; i < 100; i++ {
|
var name string
|
||||||
path := "/sys/devices/virtual/thermal/thermal_zone" + strconv.Itoa(i)
|
|
||||||
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
|
||||||
name := strings.TrimSuffix(string(file.ReadFullFile(path+"/type")), "\n")
|
|
||||||
cpu_types := []string{"x86_pkg_temp", "cpu", "CPU", "soc"}
|
cpu_types := []string{"x86_pkg_temp", "cpu", "CPU", "soc"}
|
||||||
|
stub := "/sys/devices/virtual/thermal/thermal_zone"
|
||||||
|
for i := 0; i < 100; i++ {
|
||||||
|
path = stub + strconv.Itoa(i)
|
||||||
|
if _, err := os.Stat(path); !os.IsNotExist(err) {
|
||||||
|
name = strings.TrimSuffix(string(file.ReadFullFile(path+"/type")), "\n")
|
||||||
for _, s := range cpu_types {
|
for _, s := range cpu_types {
|
||||||
if strings.HasPrefix(name, s) {
|
if strings.HasPrefix(name, s) {
|
||||||
loger.Info(fmt.Sprintf("CPU thermal zone found: %s, path: %s.", name, path))
|
loger.Info(fmt.Sprintf("CPU thermal zone found: %s, path: %s.", name, path))
|
||||||
|
@ -332,11 +334,18 @@ func GetCPUThermalZone() string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
loger.Error("CPUThermalZone not found. CPU Temp will not be displayed.")
|
if len(name) > 0 { //proves at least one zone
|
||||||
|
loger.Warn("CPU thermal zone not matched. Default to thermal_zone0.")
|
||||||
|
path = stub + "0"
|
||||||
|
} else {
|
||||||
|
loger.Error("No CPU thermal zones found. CPU temp will not be displayed.")
|
||||||
|
path = ""
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ""
|
Cache.SetDefault(keyName, path)
|
||||||
|
return path
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *systemService) GetCPUTemperature() int {
|
func (s *systemService) GetCPUTemperature() int {
|
||||||
|
|
Loading…
Reference in a new issue