mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-24 01:38:50 +02:00
fix(sensor): ignore "no data available" error
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user