Skip to content

Commit

Permalink
Merge pull request #945 from shirou/host_linux_change_to_use_sysinfo_…
Browse files Browse the repository at this point in the history
…to_get_uptime

[host][linux] Change to use unix.SysInfo_t to get Uptime in Linux
  • Loading branch information
Lomanic authored Sep 28, 2020
2 parents c5b7357 + 6c9f3bd commit 8ece829
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions host/host_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 8ece829

Please sign in to comment.