pull/1514/head
Antoine Toulme 2 years ago
parent a48fd71137
commit ca71a6db3c
No known key found for this signature in database
GPG Key ID: 63199BF2E58EE4AE

@ -73,7 +73,8 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
if useStatFile { if useStatFile {
return readBootTimeStat(ctx) return readBootTimeStat(ctx)
} else { }
filename := HostProcWithContext(ctx, "uptime") filename := HostProcWithContext(ctx, "uptime")
lines, err := ReadLines(filename) lines, err := ReadLines(filename)
if err != nil { if err != nil {
@ -91,7 +92,6 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
t := currentTime - b t := currentTime - b
return uint64(t), nil return uint64(t), nil
} }
}
func handleBootTimeFileReadErr(err error) (uint64, error) { func handleBootTimeFileReadErr(err error) (uint64, error) {
if os.IsPermission(err) { if os.IsPermission(err) {
@ -102,7 +102,7 @@ func handleBootTimeFileReadErr(err error) (uint64, error) {
} }
currentTime := time.Now().UnixNano() / int64(time.Second) currentTime := time.Now().UnixNano() / int64(time.Second)
t := currentTime - info.Uptime t := currentTime - int64(info.Uptime)
return uint64(t), nil return uint64(t), nil
} }
return 0, err return 0, err

@ -19,9 +19,9 @@ import (
"time" "time"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/shirou/gopsutil/v3/internal/common" "github.com/shirou/gopsutil/v3/internal/common"
"github.com/stretchr/testify/require"
) )
var mu sync.Mutex var mu sync.Mutex

Loading…
Cancel
Save