now support linux/arm (raspberry pi)

This commit is contained in:
WAKAYAMA shirou 2014-05-14 00:12:17 +09:00
parent 755f65b5f3
commit d5a476f628
5 changed files with 41 additions and 4 deletions

View File

@ -16,6 +16,7 @@ Available archtectures
- FreeBSD/amd64
- Linux/amd64
- Linux/arm (raspberry pi)
- Windows/amd64
(I do not have a darwin machine)

View File

@ -1,4 +1,4 @@
// +build linux,amd64
// +build linux
package gopsutil
@ -28,7 +28,7 @@ func BootTime() (int64, error) {
if err := syscall.Sysinfo(sysinfo); err != nil {
return 0, err
}
return sysinfo.Uptime, nil
return int64(sysinfo.Uptime), nil
}
func Users() ([]UserStat, error) {

27
host_linux_arm.go Normal file
View File

@ -0,0 +1,27 @@
// +build linux
// +build arm
package gopsutil
type exitStatus struct {
Etermination int16 // Process termination status.
Eexit int16 // Process exit status.
}
type timeval struct {
TvSec uint32 // Seconds.
TvUsec uint32 // Microseconds.
}
type utmp struct {
UtType int16 // Type of login.
UtPid int32 // Process ID of login process.
UtLine [32]byte // Devicename.
UtID [4]byte // Inittab ID.
UtUser [32]byte // Username.
UtHost [256]byte // Hostname for remote login.
UtExit exitStatus // Exit status of a process marked
UtSession int32 // Session ID, used for windowing.
UtTv timeval // Time entry was made.
UtAddrV6 [16]byte // Internet address of remote host.
Unused [20]byte // Reserved for future use. // original is 20
}

View File

@ -44,8 +44,8 @@ func SwapMemory() (*SwapMemoryStat, error) {
return nil, err
}
ret := &SwapMemoryStat{
Total: sysinfo.Totalswap,
Free: sysinfo.Freeswap,
Total: uint64(sysinfo.Totalswap),
Free: uint64(sysinfo.Freeswap),
}
ret.Used = ret.Total - ret.Free
ret.UsedPercent = float64(ret.Total-ret.Free) / float64(ret.Total) * 100.0

9
process_linux_arm.go Normal file
View File

@ -0,0 +1,9 @@
// +build linux
// +build arm
package gopsutil
const (
CLOCK_TICKS = 100 // C.sysconf(C._SC_CLK_TCK)
PAGESIZE = 4096 // C.sysconf(C._SC_PAGE_SIZE)
)