service: logging to syslog (#33)
* service: logging to syslog * chore: update gopsutil to v4 * chore: move println() to the util package * gpu: only return 0 on failure
This commit is contained in:
@@ -30,7 +30,7 @@ func GetGPUStat() (float64, error) {
|
||||
ioreg := exec.Command("ioreg", "-rd1", "-c", "IOAccelerator")
|
||||
gs, err := extractGPUStat(ioreg)
|
||||
if err != nil || len(gs) == 0 {
|
||||
return -1, err
|
||||
return 0, err
|
||||
}
|
||||
return gs[0], nil
|
||||
}
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
package stat
|
||||
|
||||
func GetGPUStat() (float64, error) {
|
||||
return -1, nil
|
||||
}
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func GetGPUStat() (float64, error) {
|
||||
gs, err = getAMDStat()
|
||||
}
|
||||
if err != nil || len(gs) == 0 {
|
||||
return -1, err
|
||||
return 0, err
|
||||
}
|
||||
return gs[0], nil
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
func GetGPUStat() (float64, error) {
|
||||
shellPath, err := exec.LookPath("powershell.exe")
|
||||
if err != nil || shellPath == "" {
|
||||
return -1, err
|
||||
return 0, err
|
||||
}
|
||||
cmd := exec.Command(
|
||||
shellPath,
|
||||
@@ -20,12 +20,12 @@ func GetGPUStat() (float64, error) {
|
||||
)
|
||||
output, err1 := cmd.CombinedOutput()
|
||||
if err1 != nil {
|
||||
return -1, err1
|
||||
return 0, err1
|
||||
}
|
||||
t := strings.TrimSpace(string(output))
|
||||
gs, err2 := strconv.ParseFloat(t, 64)
|
||||
if err2 != nil {
|
||||
return -1, err2
|
||||
return 0, err2
|
||||
}
|
||||
return gs, nil
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user