|
|
@@ -32,6 +32,7 @@ func systemInfoHandler(w http.ResponseWriter, r *http.Request) {
|
|
|
"cpu_usage": getCPUUsage(),
|
|
|
"cpu_cores": getCPUCore(),
|
|
|
"cpu_freq": getCPUFreq(),
|
|
|
+ "cpu_temp": getCPUTemperature(),
|
|
|
|
|
|
"mem_percent": memPercent,
|
|
|
"mem_used": memUsed,
|
|
|
@@ -136,6 +137,30 @@ func getCPUFreq() string {
|
|
|
return noValue
|
|
|
}
|
|
|
|
|
|
+func getCPUTemperature() string {
|
|
|
+ files, _ := filepath.Glob("/sys/class/thermal/thermal_zone*/temp")
|
|
|
+
|
|
|
+ max := 0
|
|
|
+
|
|
|
+ for _, f := range files {
|
|
|
+ data, err := os.ReadFile(f)
|
|
|
+ if err != nil {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+
|
|
|
+ temp, err := strconv.Atoi(strings.TrimSpace(string(data)))
|
|
|
+ if err == nil && temp > max {
|
|
|
+ max = temp
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if max == 0 {
|
|
|
+ return noValue
|
|
|
+ }
|
|
|
+
|
|
|
+ return fmt.Sprintf("%d℃", max/1000)
|
|
|
+}
|
|
|
+
|
|
|
func getMemInfo() (int, string, string) {
|
|
|
data, err := os.ReadFile("/proc/meminfo")
|
|
|
if err != nil {
|