mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-29 13:49:21 +08:00
implements Uptime.
This commit is contained in:
parent
0f76e7130f
commit
d0da149b67
@ -9,8 +9,17 @@ import (
|
|||||||
|
|
||||||
func (h Host) HostInfo() (HostInfo, error) {
|
func (h Host) HostInfo() (HostInfo, error) {
|
||||||
ret := HostInfo{}
|
ret := HostInfo{}
|
||||||
|
|
||||||
hostname, err := os.Hostname()
|
hostname, err := os.Hostname()
|
||||||
ret.Hostname = hostname
|
ret.Hostname = hostname
|
||||||
|
if err != nil {
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
|
|
||||||
|
sysinfo := &syscall.Sysinfo_t{}
|
||||||
|
if err := syscall.Sysinfo(sysinfo); err != nil {
|
||||||
|
return ret, err
|
||||||
|
}
|
||||||
ret.Uptime = sysinfo.Uptime
|
ret.Uptime = sysinfo.Uptime
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
|
Loading…
x
Reference in New Issue
Block a user