1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

linux file still exists. rename it.

This commit is contained in:
WAKAYAMA shirou 2014-04-22 12:04:16 +09:00
parent e3f496f4fe
commit 1fb41a9959
4 changed files with 41 additions and 8 deletions

38
host_freebsd.go Normal file
View File

@ -0,0 +1,38 @@
// +build freebsd
package gopsutil
import (
"os"
"strings"
"strconv"
)
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
}

View File

@ -1,4 +1,4 @@
// +build linux freebsd // +build linux
package gopsutil package gopsutil

View File

@ -3,19 +3,14 @@
package gopsutil package gopsutil
import ( import (
"os/exec"
"strconv" "strconv"
"strings"
) )
func LoadAvg() (LoadAvgStat, error) { func LoadAvg() (LoadAvgStat, error) {
out, err := exec.Command("/sbin/sysctl", "-n", "vm.loadavg").Output() values,err := do_sysctrl("vm.loadavg")
if err != nil { if err != nil {
return LoadAvgStat{}, err return LoadAvgStat{}, err
} }
v := strings.Replace(string(out), "{ ", "", 1)
v = strings.Replace(string(v), " }", "", 1)
values := strings.Fields(string(v))
load1, err := strconv.ParseFloat(values[0], 64) load1, err := strconv.ParseFloat(values[0], 64)
if err != nil { if err != nil {

View File

@ -1,4 +1,4 @@
// +build freebsd linux // +build linux
package gopsutil package gopsutil