|
|
|
@ -90,6 +90,8 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
|
|
|
|
|
if enableCache {
|
|
|
|
|
atomic.StoreUint64(&cachedBootTime, t)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return t, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
filename := HostProcWithContext(ctx, "uptime")
|
|
|
|
@ -97,6 +99,8 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return handleBootTimeFileReadErr(err)
|
|
|
|
|
}
|
|
|
|
|
currentTime := float64(time.Now().UnixNano()) / float64(time.Second)
|
|
|
|
|
|
|
|
|
|
if len(lines) != 1 {
|
|
|
|
|
return 0, fmt.Errorf("wrong uptime format")
|
|
|
|
|
}
|
|
|
|
@ -105,7 +109,6 @@ func BootTimeWithContext(ctx context.Context, enableCache bool) (uint64, error)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return 0, err
|
|
|
|
|
}
|
|
|
|
|
currentTime := float64(time.Now().UnixNano()) / float64(time.Second)
|
|
|
|
|
t := currentTime - b
|
|
|
|
|
|
|
|
|
|
if enableCache {
|
|
|
|
|