mirror of
https://github.com/fankes/beszel.git
synced 2025-10-19 09:49:28 +08:00
feat: PRIMARY_SENSOR env var to choose dashboard temp
This commit is contained in:
@@ -223,8 +223,10 @@ func (a *Agent) updateTemperatures(systemStats *system.Stats) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
primarySensor, primarySensorIsDefined := GetEnv("PRIMARY_SENSOR")
|
||||||
|
|
||||||
// reset high temp
|
// reset high temp
|
||||||
a.systemInfo.HighTemp = 0
|
a.systemInfo.DashboardTemp = 0
|
||||||
|
|
||||||
// get sensor data
|
// get sensor data
|
||||||
temps, err := sensors.TemperaturesWithContext(a.sensorsContext)
|
temps, err := sensors.TemperaturesWithContext(a.sensorsContext)
|
||||||
@@ -255,7 +257,14 @@ func (a *Agent) updateTemperatures(systemStats *system.Stats) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
a.systemInfo.HighTemp = max(a.systemInfo.HighTemp, sensor.Temperature)
|
// set dashboard temperature
|
||||||
|
if primarySensorIsDefined {
|
||||||
|
if sensorName == primarySensor {
|
||||||
|
a.systemInfo.DashboardTemp = sensor.Temperature
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a.systemInfo.DashboardTemp = max(a.systemInfo.DashboardTemp, sensor.Temperature)
|
||||||
|
}
|
||||||
systemStats.Temperatures[sensorName] = twoDecimals(sensor.Temperature)
|
systemStats.Temperatures[sensorName] = twoDecimals(sensor.Temperature)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@@ -76,7 +76,7 @@ type Info struct {
|
|||||||
AgentVersion string `json:"v"`
|
AgentVersion string `json:"v"`
|
||||||
Podman bool `json:"p,omitempty"`
|
Podman bool `json:"p,omitempty"`
|
||||||
GpuPct float64 `json:"g,omitempty"`
|
GpuPct float64 `json:"g,omitempty"`
|
||||||
HighTemp float64 `json:"ht,omitempty"`
|
DashboardTemp float64 `json:"dt,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Final data structure to return to the hub
|
// Final data structure to return to the hub
|
||||||
|
@@ -193,7 +193,7 @@ export default function SystemsTable() {
|
|||||||
header: sortableHeader,
|
header: sortableHeader,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
accessorFn: (originalRow) => originalRow.info.ht,
|
accessorFn: (originalRow) => originalRow.info.dt,
|
||||||
id: t`Temp`,
|
id: t`Temp`,
|
||||||
invertSorting: true,
|
invertSorting: true,
|
||||||
sortUndefined: -1,
|
sortUndefined: -1,
|
||||||
|
4
beszel/site/src/types.d.ts
vendored
4
beszel/site/src/types.d.ts
vendored
@@ -45,8 +45,8 @@ export interface SystemInfo {
|
|||||||
p?: boolean
|
p?: boolean
|
||||||
/** highest gpu utilization */
|
/** highest gpu utilization */
|
||||||
g?: number
|
g?: number
|
||||||
/** highest temperature */
|
/** dashboard display temperature */
|
||||||
ht?: number
|
dt?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SystemStats {
|
export interface SystemStats {
|
||||||
|
Reference in New Issue
Block a user