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
This commit is contained in:
Lomanic 2020-09-28 19:47:15 +02:00 committed by GitHub
commit 8ece829fb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -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) {