Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Canread
Gopsutil
提交
45dcaa3b
G
Gopsutil
项目概览
Canread
/
Gopsutil
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
Gopsutil
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
45dcaa3b
编写于
11月 24, 2015
作者:
N
Nikolay Sivko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
process[freebsd]: Cmdline, IOCounters, CPUTimes implemented
上级
d49c4afc
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
103 addition
and
16 deletion
+103
-16
process/process_freebsd.go
process/process_freebsd.go
+41
-13
process/process_freebsd_386.go
process/process_freebsd_386.go
+31
-1
process/process_freebsd_amd64.go
process/process_freebsd_amd64.go
+31
-2
未找到文件。
process/process_freebsd.go
浏览文件 @
45dcaa3b
...
...
@@ -6,6 +6,8 @@ import (
"bytes"
"encoding/binary"
"unsafe"
"strings"
"syscall"
cpu
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/internal/common"
...
...
@@ -53,7 +55,19 @@ func (p *Process) Exe() (string, error) {
return
""
,
common
.
NotImplementedError
}
func
(
p
*
Process
)
Cmdline
()
(
string
,
error
)
{
return
""
,
common
.
NotImplementedError
mib
:=
[]
int32
{
CTLKern
,
KernProc
,
KernProcArgs
,
p
.
Pid
}
buf
,
_
,
err
:=
common
.
CallSyscall
(
mib
)
if
err
!=
nil
{
return
""
,
err
}
ret
:=
strings
.
FieldsFunc
(
string
(
buf
),
func
(
r
rune
)
bool
{
if
r
==
'\u0000'
{
return
true
}
return
false
})
return
strings
.
Join
(
ret
,
" "
),
nil
}
func
(
p
*
Process
)
CreateTime
()
(
int64
,
error
)
{
return
0
,
common
.
NotImplementedError
...
...
@@ -121,7 +135,14 @@ func (p *Process) Rlimit() ([]RlimitStat, error) {
return
rlimit
,
common
.
NotImplementedError
}
func
(
p
*
Process
)
IOCounters
()
(
*
IOCountersStat
,
error
)
{
return
nil
,
common
.
NotImplementedError
k
,
err
:=
p
.
getKProc
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
IOCountersStat
{
ReadCount
:
uint64
(
k
.
KiRusage
.
Inblock
),
WriteCount
:
uint64
(
k
.
KiRusage
.
Oublock
),
},
nil
}
func
(
p
*
Process
)
NumCtxSwitches
()
(
*
NumCtxSwitchesStat
,
error
)
{
return
nil
,
common
.
NotImplementedError
...
...
@@ -142,7 +163,15 @@ func (p *Process) Threads() (map[string]string, error) {
return
ret
,
common
.
NotImplementedError
}
func
(
p
*
Process
)
CPUTimes
()
(
*
cpu
.
CPUTimesStat
,
error
)
{
return
nil
,
common
.
NotImplementedError
k
,
err
:=
p
.
getKProc
()
if
err
!=
nil
{
return
nil
,
err
}
return
&
cpu
.
CPUTimesStat
{
CPU
:
"cpu"
,
User
:
float64
(
k
.
KiRusage
.
Utime
.
Sec
)
+
float64
(
k
.
KiRusage
.
Utime
.
Usec
)
/
1000000
,
System
:
float64
(
k
.
KiRusage
.
Stime
.
Sec
)
+
float64
(
k
.
KiRusage
.
Stime
.
Usec
)
/
1000000
,
},
nil
}
func
(
p
*
Process
)
CPUAffinity
()
([]
int32
,
error
)
{
return
nil
,
common
.
NotImplementedError
...
...
@@ -152,13 +181,16 @@ func (p *Process) MemoryInfo() (*MemoryInfoStat, error) {
if
err
!=
nil
{
return
nil
,
err
}
ret
:=
&
MemoryInfoStat
{
RSS
:
uint64
(
k
.
KiRssize
),
VMS
:
uint64
(
k
.
KiSize
),
v
,
err
:=
syscall
.
Sysctl
(
"vm.stats.vm.v_page_size"
)
if
err
!=
nil
{
return
nil
,
err
}
pageSize
:=
binary
.
LittleEndian
.
Uint16
([]
byte
(
v
))
return
ret
,
nil
return
&
MemoryInfoStat
{
RSS
:
uint64
(
k
.
KiRssize
)
*
uint64
(
pageSize
),
VMS
:
uint64
(
k
.
KiSize
),
},
nil
}
func
(
p
*
Process
)
MemoryInfoEx
()
(
*
MemoryInfoExStat
,
error
)
{
return
nil
,
common
.
NotImplementedError
...
...
@@ -241,11 +273,7 @@ func parseKinfoProc(buf []byte) (KinfoProc, error) {
var
k
KinfoProc
br
:=
bytes
.
NewReader
(
buf
)
err
:=
binary
.
Read
(
br
,
binary
.
LittleEndian
,
&
k
)
if
err
!=
nil
{
return
k
,
err
}
return
k
,
nil
return
k
,
err
}
func
(
p
*
Process
)
getKProc
()
(
*
KinfoProc
,
error
)
{
...
...
process/process_freebsd_386.go
浏览文件 @
45dcaa3b
...
...
@@ -10,8 +10,38 @@ const (
KernProcPID
=
1
// by process id
KernProcProc
=
8
// only return procs
KernProcPathname
=
12
// path to executable
KernProcArgs
=
7
// get/set arguments/proctitle
)
type
Timespec
struct
{
Sec
int32
Nsec
int32
}
type
Timeval
struct
{
Sec
int32
Usec
int32
}
type
Rusage
struct
{
Utime
Timeval
Stime
Timeval
Maxrss
int32
Ixrss
int32
Idrss
int32
Isrss
int32
Minflt
int32
Majflt
int32
Nswap
int32
Inblock
int32
Oublock
int32
Msgsnd
int32
Msgrcv
int32
Nsignals
int32
Nvcsw
int32
Nivcsw
int32
}
// copied from sys/user.h
type
KinfoProc
struct
{
KiStructsize
int32
...
...
@@ -83,7 +113,7 @@ type KinfoProc struct {
KiNumthreads
int32
KiTid
int32
KiPri
int32
KiRusage
[
72
]
byt
e
KiRusage
Rusag
e
KiRusageCh
[
72
]
byte
KiPcb
int32
KiKstack
int32
...
...
process/process_freebsd_amd64.go
浏览文件 @
45dcaa3b
// +build freebsd
// +build amd64
package
process
// copied from sys/sysctl.h
...
...
@@ -10,8 +9,38 @@ const (
KernProcPID
=
1
// by process id
KernProcProc
=
8
// only return procs
KernProcPathname
=
12
// path to executable
KernProcArgs
=
7
// get/set arguments/proctitle
)
type
Timespec
struct
{
Sec
int64
Nsec
int64
}
type
Timeval
struct
{
Sec
int64
Usec
int64
}
type
Rusage
struct
{
Utime
Timeval
Stime
Timeval
Maxrss
int64
Ixrss
int64
Idrss
int64
Isrss
int64
Minflt
int64
Majflt
int64
Nswap
int64
Inblock
int64
Oublock
int64
Msgsnd
int64
Msgrcv
int64
Nsignals
int64
Nvcsw
int64
Nivcsw
int64
}
// copied from sys/user.h
type
KinfoProc
struct
{
KiStructsize
int32
...
...
@@ -83,7 +112,7 @@ type KinfoProc struct {
KiNumthreads
int32
KiTid
int32
KiPri
int32
KiRusage
[
144
]
byt
e
KiRusage
Rusag
e
KiRusageCh
[
144
]
byte
KiPcb
int64
KiKstack
int64
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录