mirror of
https://github.com/yusing/godoxy.git
synced 2025-07-09 07:54:03 +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"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/shirou/gopsutil/v4/cpu"
|
"github.com/shirou/gopsutil/v4/cpu"
|
||||||
|
@ -71,6 +72,10 @@ func _() { // check if this behavior is not changed
|
||||||
var _ sensors.Warnings = disk.Warnings{}
|
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) {
|
func getSystemInfo(ctx context.Context, lastResult *SystemInfo) (*SystemInfo, error) {
|
||||||
errs := gperr.NewBuilder("failed to get system info")
|
errs := gperr.NewBuilder("failed to get system info")
|
||||||
var s SystemInfo
|
var s SystemInfo
|
||||||
|
@ -99,6 +104,9 @@ func getSystemInfo(ctx context.Context, lastResult *SystemInfo) (*SystemInfo, er
|
||||||
warnings := new(warning.Warning)
|
warnings := new(warning.Warning)
|
||||||
if errors.As(err, &warnings) {
|
if errors.As(err, &warnings) {
|
||||||
for _, warning := range warnings.List {
|
for _, warning := range warnings.List {
|
||||||
|
if isNoDataAvailable(warning) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
allWarnings.Add(warning)
|
allWarnings.Add(warning)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Reference in a new issue