mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-19 20:32:35 +02:00
fix(sensor): ignore "no data available" error
This commit is contained in:
parent
9eae809690
commit
4df31263b5
1 changed files with 8 additions and 0 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
"github.com/shirou/gopsutil/v4/cpu"
|
||||
|
@ -71,6 +72,10 @@ func _() { // check if this behavior is not changed
|
|||
var _ sensors.Warnings = disk.Warnings{}
|
||||
}
|
||||
|
||||
func isNoDataAvailable(err error) bool {
|
||||
return errors.Is(err, syscall.ENODATA)
|
||||
}
|
||||
|
||||
func getSystemInfo(ctx context.Context, lastResult *SystemInfo) (*SystemInfo, error) {
|
||||
errs := gperr.NewBuilder("failed to get system info")
|
||||
var s SystemInfo
|
||||
|
@ -99,6 +104,9 @@ func getSystemInfo(ctx context.Context, lastResult *SystemInfo) (*SystemInfo, er
|
|||
warnings := new(warning.Warning)
|
||||
if errors.As(err, &warnings) {
|
||||
for _, warning := range warnings.List {
|
||||
if isNoDataAvailable(warning) {
|
||||
continue
|
||||
}
|
||||
allWarnings.Add(warning)
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue