FreeBSD Fixes
- Added NVIDIA GPU Temperature Support - Fixed a bug where CPU temp would not be displayed if a syctl option was not found - Fixed a bug where Swap was not being displayed on mirroed ZFS partitions.
This commit is contained in:
parent
e1f3488c4c
commit
aa496ba38d
|
@ -42,7 +42,10 @@ func gatherSwapInfo() (MemoryInfo, error) {
|
|||
}
|
||||
}
|
||||
|
||||
ss := strings.Split(strings.TrimSuffix(string(output), "\n"), " ")
|
||||
s := strings.TrimSuffix(string(output), "\n")
|
||||
s = strings.ReplaceAll(s, "\n", " ")
|
||||
ss := strings.Split(s, " ")
|
||||
ss = ss[((len(ss)/3)-1)*3:]
|
||||
|
||||
return convert(ss)
|
||||
}
|
||||
|
|
|
@ -35,22 +35,60 @@ func refineOutput(output []byte) (float64, error) {
|
|||
return value, nil
|
||||
}
|
||||
|
||||
func collectNvidiaGPUSensors() []sensorMeasurement {
|
||||
var measurements []sensorMeasurement
|
||||
|
||||
_, err := exec.Command("sysctl", "-n", "hw.nvidia.gpus.0.model").Output()
|
||||
if err == nil {
|
||||
output, err := exec.Command("nvidia-settings", "-q", "gpucoretemp", "-t").Output()
|
||||
if err != nil {
|
||||
log.Printf("Failed to get nvidia gpu temperature from nvidia-settings")
|
||||
} else {
|
||||
s := strings.TrimSuffix(string(output), "\n")
|
||||
s = strings.ReplaceAll(s, "\n", " ")
|
||||
ss := strings.Split(s, " ")
|
||||
for i := 1; i < len(ss); i++ {
|
||||
value, err := refineOutput([]byte(ss[i]))
|
||||
if err != nil {
|
||||
log.Printf("Failed to parse nvidia-settings output")
|
||||
}
|
||||
label := fmt.Sprintf("Nvidia GPU %d", i-1)
|
||||
measurements = append(measurements, sensorMeasurement{label, value})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return measurements
|
||||
}
|
||||
|
||||
func collectGPUSensors() []sensorMeasurement {
|
||||
var measurements []sensorMeasurement
|
||||
|
||||
m := collectNvidiaGPUSensors()
|
||||
measurements = append(measurements, m...)
|
||||
|
||||
return measurements
|
||||
}
|
||||
|
||||
func collectSensors() ([]sensorMeasurement, error) {
|
||||
var measurements []sensorMeasurement
|
||||
for k, v := range sensorOIDS {
|
||||
output, err := exec.Command("sysctl", "-n", k).Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute 'sysctl' command: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
value, err := refineOutput(output)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to execute 'sysctl' command: %v", err)
|
||||
continue
|
||||
}
|
||||
|
||||
measurements = append(measurements, sensorMeasurement{v, value})
|
||||
|
||||
}
|
||||
|
||||
m := collectGPUSensors()
|
||||
measurements = append(measurements, m...)
|
||||
|
||||
return measurements, nil
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user