Skip to content

Commit efc0d8c

Browse files
committed
Add thermal throttled data
1 parent 88678df commit efc0d8c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

main.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ type CPUMetrics struct {
8282
CoreMetrics map[string]int
8383
CPUW, GPUW, PackageW float64
8484
CoreUsages []float64
85+
Throttled bool
8586
}
8687

8788
type NetDiskMetrics struct {
@@ -1231,7 +1232,15 @@ func updateCPUUI(cpuMetrics CPUMetrics) {
12311232
totalUsage,
12321233
)
12331234
PowerChart.Title = fmt.Sprintf("%.2f W CPU - %.2f W GPU", cpuMetrics.CPUW, cpuMetrics.GPUW)
1234-
PowerChart.Text = fmt.Sprintf("CPU Power: %.2f W\nGPU Power: %.2f W\nTotal Power: %.2f W", cpuMetrics.CPUW, cpuMetrics.GPUW, cpuMetrics.PackageW)
1235+
PowerChart.Text = fmt.Sprintf("CPU Power: %.2f W\nGPU Power: %.2f W\nTotal Power: %.2f W\nThermals: %s",
1236+
cpuMetrics.CPUW,
1237+
cpuMetrics.GPUW,
1238+
cpuMetrics.PackageW,
1239+
map[bool]string{
1240+
true: "Throttled!",
1241+
false: "Nominal",
1242+
}[cpuMetrics.Throttled],
1243+
)
12351244
memoryMetrics := getMemoryMetrics()
12361245
memoryGauge.Title = fmt.Sprintf("Memory Usage: %.2f GB / %.2f GB (Swap: %.2f/%.2f GB)", float64(memoryMetrics.Used)/1024/1024/1024, float64(memoryMetrics.Total)/1024/1024/1024, float64(memoryMetrics.SwapUsed)/1024/1024/1024, float64(memoryMetrics.SwapTotal)/1024/1024/1024)
12371246
memoryGauge.Percent = int((float64(memoryMetrics.Used) / float64(memoryMetrics.Total)) * 100)
@@ -1297,6 +1306,14 @@ func parseCPUMetrics(data map[string]interface{}, cpuMetrics CPUMetrics) CPUMetr
12971306
stderrLogger.Fatalf("Failed to get processor data\n")
12981307
return cpuMetrics
12991308
}
1309+
1310+
thermal, ok := data["thermal_pressure"].(string)
1311+
if !ok {
1312+
stderrLogger.Fatalf("Failed to get thermal data\n")
1313+
}
1314+
1315+
cpuMetrics.Throttled = thermal != "Nominal"
1316+
13001317
eCores := []int{}
13011318
pCores := []int{}
13021319
cpuMetrics.ECores = eCores
@@ -1311,6 +1328,7 @@ func parseCPUMetrics(data map[string]interface{}, cpuMetrics CPUMetrics) CPUMetr
13111328
if combinedPower, ok := processor["combined_power"].(float64); ok {
13121329
cpuMetrics.PackageW = float64(combinedPower) / 1000
13131330
}
1331+
13141332
return cpuMetrics
13151333
}
13161334

0 commit comments

Comments
 (0)