From 6c9f3bdcae3cd68d3e80eacf19eafe0efe0a4ea8 Mon Sep 17 00:00:00 2001 From: shirou Date: Sat, 19 Sep 2020 11:12:05 +0900 Subject: [PATCH] [host][linux] Change to use unix.SysInfo_t to get Uptime in Linux --- host/host_linux.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/host/host_linux.go b/host/host_linux.go index 29cadce6c..739aa93b7 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -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) {