mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-29 13:49:21 +08:00
golint on freebsd.
This commit is contained in:
parent
d511748bfd
commit
e4cee3c190
@ -23,7 +23,7 @@ const (
|
|||||||
|
|
||||||
// TODO: get per cpus
|
// TODO: get per cpus
|
||||||
func CPUTimes(percpu bool) ([]CPUTimesStat, error) {
|
func CPUTimes(percpu bool) ([]CPUTimesStat, error) {
|
||||||
var ret []CPU_TimesStat
|
var ret []CPUTimesStat
|
||||||
|
|
||||||
cpuTime, err := doSysctrl("kern.cp_time")
|
cpuTime, err := doSysctrl("kern.cp_time")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
|
func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
|
||||||
var ret []Disk_partitionStat
|
var ret []DiskPartitionStat
|
||||||
|
|
||||||
// get length
|
// get length
|
||||||
count, err := syscall.Getfsstat(nil, MNT_WAIT)
|
count, err := syscall.Getfsstat(nil, MNT_WAIT)
|
||||||
@ -22,56 +22,56 @@ func DiskPartitions(all bool) ([]DiskPartitionStat, error) {
|
|||||||
|
|
||||||
for _, stat := range fs {
|
for _, stat := range fs {
|
||||||
opts := "rw"
|
opts := "rw"
|
||||||
if stat.F_flags&MNT_RDONLY != 0 {
|
if stat.FFlags&MNT_RDONLY != 0 {
|
||||||
opts = "ro"
|
opts = "ro"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_SYNCHRONOUS != 0 {
|
if stat.FFlags&MNT_SYNCHRONOUS != 0 {
|
||||||
opts += ",sync"
|
opts += ",sync"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_NOEXEC != 0 {
|
if stat.FFlags&MNT_NOEXEC != 0 {
|
||||||
opts += ",noexec"
|
opts += ",noexec"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_NOSUID != 0 {
|
if stat.FFlags&MNT_NOSUID != 0 {
|
||||||
opts += ",nosuid"
|
opts += ",nosuid"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_UNION != 0 {
|
if stat.FFlags&MNT_UNION != 0 {
|
||||||
opts += ",union"
|
opts += ",union"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_ASYNC != 0 {
|
if stat.FFlags&MNT_ASYNC != 0 {
|
||||||
opts += ",async"
|
opts += ",async"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_SUIDDIR != 0 {
|
if stat.FFlags&MNT_SUIDDIR != 0 {
|
||||||
opts += ",suiddir"
|
opts += ",suiddir"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_SOFTDEP != 0 {
|
if stat.FFlags&MNT_SOFTDEP != 0 {
|
||||||
opts += ",softdep"
|
opts += ",softdep"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_NOSYMFOLLOW != 0 {
|
if stat.FFlags&MNT_NOSYMFOLLOW != 0 {
|
||||||
opts += ",nosymfollow"
|
opts += ",nosymfollow"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_GJOURNAL != 0 {
|
if stat.FFlags&MNT_GJOURNAL != 0 {
|
||||||
opts += ",gjounalc"
|
opts += ",gjounalc"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_MULTILABEL != 0 {
|
if stat.FFlags&MNT_MULTILABEL != 0 {
|
||||||
opts += ",multilabel"
|
opts += ",multilabel"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_ACLS != 0 {
|
if stat.FFlags&MNT_ACLS != 0 {
|
||||||
opts += ",acls"
|
opts += ",acls"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_NOATIME != 0 {
|
if stat.FFlags&MNT_NOATIME != 0 {
|
||||||
opts += ",noattime"
|
opts += ",noattime"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_NOCLUSTERR != 0 {
|
if stat.FFlags&MNT_NOCLUSTERR != 0 {
|
||||||
opts += ",nocluster"
|
opts += ",nocluster"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_NOCLUSTERW != 0 {
|
if stat.FFlags&MNT_NOCLUSTERW != 0 {
|
||||||
opts += ",noclusterw"
|
opts += ",noclusterw"
|
||||||
}
|
}
|
||||||
if stat.F_flags&MNT_NFS4ACLS != 0 {
|
if stat.FFlags&MNT_NFS4ACLS != 0 {
|
||||||
opts += ",nfs4acls"
|
opts += ",nfs4acls"
|
||||||
}
|
}
|
||||||
|
|
||||||
d := Disk_partitionStat{
|
d := DiskPartitionStat{
|
||||||
Mountpoint: byteToString(stat.FMntonname[:]),
|
Mountpoint: byteToString(stat.FMntonname[:]),
|
||||||
Fstype: byteToString(stat.FFstypename[:]),
|
Fstype: byteToString(stat.FFstypename[:]),
|
||||||
Opts: opts,
|
Opts: opts,
|
||||||
|
@ -68,10 +68,10 @@ func Users() ([]UserStat, error) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
user := UserStat{
|
user := UserStat{
|
||||||
User: byteToString(u.Ut_name[:]),
|
User: byteToString(u.UtName[:]),
|
||||||
Terminal: byteToString(u.Ut_line[:]),
|
Terminal: byteToString(u.UtLine[:]),
|
||||||
Host: byteToString(u.Ut_host[:]),
|
Host: byteToString(u.UtHost[:]),
|
||||||
Started: int(u.Ut_time),
|
Started: int(u.UtTime),
|
||||||
}
|
}
|
||||||
ret = append(ret, user)
|
ret = append(ret, user)
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,13 @@
|
|||||||
package gopsutil
|
package gopsutil
|
||||||
|
|
||||||
func VirtualMemory() (VirtualMemoryStat, error) {
|
func VirtualMemory() (VirtualMemoryStat, error) {
|
||||||
ret := Virtual_memoryStat{}
|
ret := VirtualMemoryStat{}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SwapMemory() (SwapMemoryStat, error) {
|
func SwapMemory() (SwapMemoryStat, error) {
|
||||||
ret := Swap_memoryStat{}
|
ret := SwapMemoryStat{}
|
||||||
|
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
|
|||||||
return &ret, errors.New("not implemented yet")
|
return &ret, errors.New("not implemented yet")
|
||||||
}
|
}
|
||||||
|
|
||||||
func copyParams(k *Kinfo_proc, p *Process) error {
|
func copyParams(k *KinfoProc, p *Process) error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ func processes() ([]Process, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get kinfo_proc size
|
// get kinfo_proc size
|
||||||
k := Kinfo_proc{}
|
k := KinfoProc{}
|
||||||
procinfoLen := int(unsafe.Sizeof(k))
|
procinfoLen := int(unsafe.Sizeof(k))
|
||||||
count := int(length / uint64(procinfoLen))
|
count := int(length / uint64(procinfoLen))
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ func processes() ([]Process, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
p, err := NewProcess(int32(k.Ki_pid))
|
p, err := NewProcess(int32(k.KiPid))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@ -223,7 +223,7 @@ func NewProcess(pid int32) (*Process, error) {
|
|||||||
p := &Process{Pid: pid}
|
p := &Process{Pid: pid}
|
||||||
mib := []int32{CTL_KERN, KERN_PROC, KERN_PROC_PID, p.Pid}
|
mib := []int32{CTL_KERN, KERN_PROC, KERN_PROC_PID, p.Pid}
|
||||||
|
|
||||||
buf, length, err := call_syscall(mib)
|
buf, length, err := callSyscall(mib)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user