Merge pull request #945 from shirou/host_linux_change_to_use_sysinfo_to_get_uptime

[host][linux] Change to use unix.SysInfo_t to get Uptime in Linux
tags/v2.20.9
Lomanic 5 years ago committed by GitHub
commit 8ece829fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -70,11 +70,11 @@ func BootTimeWithContext(ctx context.Context) (uint64, error) {
}
func UptimeWithContext(ctx context.Context) (uint64, error) {
boot, err := BootTime()
if err != nil {
sysinfo := &unix.Sysinfo_t{}
if err := unix.Sysinfo(sysinfo); err != nil {
return 0, err
}
return timeSince(boot), nil
return uint64(sysinfo.Uptime), nil
}
func UsersWithContext(ctx context.Context) ([]UserStat, error) {

Loading…
Cancel
Save