1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-28 13:48:49 +08:00
shirou_gopsutil/host_freebsd.go
WAKAYAMA shirou 7d1ba2a9df go fmt
2014-04-22 12:43:31 +09:00

38 lines
593 B
Go

// +build freebsd
package gopsutil
import (
"os"
"strconv"
"strings"
)
func HostInfo() (HostInfoStat, error) {
ret := HostInfoStat{}
hostname, err := os.Hostname()
ret.Hostname = hostname
if err != nil {
return ret, err
}
return ret, nil
}
func Boot_time() (int64, error) {
values, err := do_sysctrl("kern.boottime")
if err != nil {
return 0, err
}
// ex: { sec = 1392261637, usec = 627534 } Thu Feb 13 12:20:37 2014
v := strings.Replace(values[2], ",", "", 1)
boottime, err := strconv.ParseInt(v, 10, 64)
if err != nil {
return 0, err
}
return boottime, nil
}