Skip to content

Commit

Permalink
[host][linux] Change to use unix.SysInfo_t to get Uptime in Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
shirou committed Sep 19, 2020
1 parent c5b7357 commit 6c9f3bd
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 6c9f3bd

Please sign in to comment.