[host][linux] Change to use unix.SysInfo_t to get Uptime in Linux

pull/945/head
shirou 5 years ago
parent c5b7357407
commit 6c9f3bdcae

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

Loading…
Cancel
Save