mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-26 13:48:59 +08:00
[host][linux] Change to use unix.SysInfo_t to get Uptime in Linux
This commit is contained in:
parent
c5b7357407
commit
6c9f3bdcae
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user