Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Canread
Gopsutil
提交
f5a85e6b
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,发现更多精彩内容 >>
提交
f5a85e6b
编写于
5月 20, 2014
作者:
S
Shirou WAKAYAMA
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of github.com:shirou/gopsutil
上级
15ddbe00
5ae1c917
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
137 addition
and
77 deletion
+137
-77
README.rst
README.rst
+1
-1
common.go
common.go
+3
-3
cpu_freebsd.go
cpu_freebsd.go
+3
-3
cpu_linux.go
cpu_linux.go
+5
-5
disk_linux.go
disk_linux.go
+6
-6
host.go
host.go
+1
-1
host_freebsd.go
host_freebsd.go
+24
-2
host_linux.go
host_linux.go
+6
-2
host_windows.go
host_windows.go
+3
-3
mem_freebsd.go
mem_freebsd.go
+12
-12
net_freebsd.go
net_freebsd.go
+36
-2
net_linux.go
net_linux.go
+7
-7
process_linux.go
process_linux.go
+30
-30
未找到文件。
README.rst
浏览文件 @
f5a85e6b
...
...
@@ -102,7 +102,7 @@ Current Status
- disk_partitions (linux, freebsd, windows)
- disk_io_counters (linux)
- disk_usage (linux, freebsd, windows)
- net_io_counters (linux, windows)
- net_io_counters (linux,
freebsd,
windows)
- boot_time (linux, freebsd, windows(but little broken))
- users (linux, freebsd)
- pids (linux, freebsd)
...
...
common.go
浏览文件 @
f5a85e6b
...
...
@@ -58,19 +58,19 @@ func byteToString(orig []byte) string {
}
// Parse to int32 without error
func
p
arseInt32
(
val
string
)
int32
{
func
mustP
arseInt32
(
val
string
)
int32
{
vv
,
_
:=
strconv
.
ParseInt
(
val
,
10
,
32
)
return
int32
(
vv
)
}
// Parse to uint64 without error
func
p
arseUint64
(
val
string
)
uint64
{
func
mustP
arseUint64
(
val
string
)
uint64
{
vv
,
_
:=
strconv
.
ParseInt
(
val
,
10
,
64
)
return
uint64
(
vv
)
}
// Parse to Float64 without error
func
p
arseFloat64
(
val
string
)
float64
{
func
mustP
arseFloat64
(
val
string
)
float64
{
vv
,
_
:=
strconv
.
ParseFloat
(
val
,
64
)
return
vv
}
...
...
cpu_freebsd.go
浏览文件 @
f5a85e6b
...
...
@@ -62,12 +62,12 @@ func CPUInfo() ([]CPUInfoStat, error) {
for
_
,
line
:=
range
lines
{
if
matches
:=
regexp
.
MustCompile
(
`CPU:\s+(.+) \(([\d.]+).+\)`
)
.
FindStringSubmatch
(
line
);
matches
!=
nil
{
c
.
ModelName
=
matches
[
1
]
c
.
Mhz
=
p
arseFloat64
(
matches
[
2
])
c
.
Mhz
=
mustP
arseFloat64
(
matches
[
2
])
}
else
if
matches
:=
regexp
.
MustCompile
(
`Origin = "(.+)" Id = (.+) Family = (.+) Model = (.+) Stepping = (.+)`
)
.
FindStringSubmatch
(
line
);
matches
!=
nil
{
c
.
VendorID
=
matches
[
1
]
c
.
Family
=
matches
[
3
]
c
.
Model
=
matches
[
4
]
c
.
Stepping
=
p
arseInt32
(
matches
[
5
])
c
.
Stepping
=
mustP
arseInt32
(
matches
[
5
])
}
else
if
matches
:=
regexp
.
MustCompile
(
`Features=.+<(.+)>`
)
.
FindStringSubmatch
(
line
);
matches
!=
nil
{
for
_
,
v
:=
range
strings
.
Split
(
matches
[
1
],
","
)
{
c
.
Flags
=
append
(
c
.
Flags
,
strings
.
ToLower
(
v
))
...
...
@@ -78,7 +78,7 @@ func CPUInfo() ([]CPUInfoStat, error) {
}
}
else
if
matches
:=
regexp
.
MustCompile
(
`Logical CPUs per core: (\d+)`
)
.
FindStringSubmatch
(
line
);
matches
!=
nil
{
// FIXME: no this line?
c
.
Cores
=
p
arseInt32
(
matches
[
1
])
c
.
Cores
=
mustP
arseInt32
(
matches
[
1
])
}
}
...
...
cpu_linux.go
浏览文件 @
f5a85e6b
...
...
@@ -46,7 +46,7 @@ func CPUInfo() ([]CPUInfoStat, error) {
switch
key
{
case
"processor"
:
c
=
CPUInfoStat
{}
c
.
CPU
=
p
arseInt32
(
value
)
c
.
CPU
=
mustP
arseInt32
(
value
)
case
"vendor_id"
:
c
.
VendorID
=
value
case
"cpu family"
:
...
...
@@ -56,17 +56,17 @@ func CPUInfo() ([]CPUInfoStat, error) {
case
"model name"
:
c
.
ModelName
=
value
case
"stepping"
:
c
.
Stepping
=
p
arseInt32
(
value
)
c
.
Stepping
=
mustP
arseInt32
(
value
)
case
"cpu MHz"
:
c
.
Mhz
=
p
arseFloat64
(
value
)
c
.
Mhz
=
mustP
arseFloat64
(
value
)
case
"cache size"
:
c
.
CacheSize
=
p
arseInt32
(
strings
.
Replace
(
value
,
" KB"
,
""
,
1
))
c
.
CacheSize
=
mustP
arseInt32
(
strings
.
Replace
(
value
,
" KB"
,
""
,
1
))
case
"physical id"
:
c
.
PhysicalID
=
value
case
"core id"
:
c
.
CoreID
=
value
case
"cpu cores"
:
c
.
Cores
=
p
arseInt32
(
value
)
c
.
Cores
=
mustP
arseInt32
(
value
)
case
"flags"
:
c
.
Flags
=
strings
.
Split
(
value
,
","
)
}
...
...
disk_linux.go
浏览文件 @
f5a85e6b
...
...
@@ -69,12 +69,12 @@ func DiskIOCounters() (map[string]DiskIOCountersStat, error) {
for
_
,
line
:=
range
lines
{
fields
:=
strings
.
Fields
(
line
)
name
:=
fields
[
2
]
reads
:=
p
arseUint64
(
fields
[
3
])
rbytes
:=
p
arseUint64
(
fields
[
5
])
rtime
:=
p
arseUint64
(
fields
[
6
])
writes
:=
p
arseUint64
(
fields
[
7
])
wbytes
:=
p
arseUint64
(
fields
[
9
])
wtime
:=
p
arseUint64
(
fields
[
10
])
reads
:=
mustP
arseUint64
(
fields
[
3
])
rbytes
:=
mustP
arseUint64
(
fields
[
5
])
rtime
:=
mustP
arseUint64
(
fields
[
6
])
writes
:=
mustP
arseUint64
(
fields
[
7
])
wbytes
:=
mustP
arseUint64
(
fields
[
9
])
wtime
:=
mustP
arseUint64
(
fields
[
10
])
if
stringContains
(
partitions
,
name
)
{
d
:=
DiskIOCountersStat
{
Name
:
name
,
...
...
host.go
浏览文件 @
f5a85e6b
...
...
@@ -8,7 +8,7 @@ import (
// This is not in the psutil but it useful.
type
HostInfoStat
struct
{
Hostname
string
`json:"hostname"`
Uptime
int64
`json:"uptime"`
Uptime
uint64
`json:"uptime"`
Procs
uint64
`json:"procs"`
// number of processes
OS
string
`json:"os"`
// ex: freebsd, linux
Platform
string
`json:"platform"`
// ex: ubuntu, linuxmint
...
...
host_freebsd.go
浏览文件 @
f5a85e6b
...
...
@@ -7,19 +7,41 @@ import (
"encoding/binary"
"io/ioutil"
"os"
"os/exec"
"runtime"
"strconv"
"strings"
"unsafe"
)
func
HostInfo
()
(
*
HostInfoStat
,
error
)
{
ret
:=
&
HostInfoStat
{}
ret
:=
&
HostInfoStat
{
OS
:
runtime
.
GOOS
,
PlatformFamily
:
"freebsd"
,
}
hostname
,
err
:=
os
.
Hostname
()
ret
.
Hostname
=
hostname
if
err
!=
nil
{
return
ret
,
err
}
ret
.
Hostname
=
hostname
out
,
err
:=
exec
.
Command
(
"uname"
,
"-s"
)
.
Output
()
if
err
==
nil
{
ret
.
Platform
=
strings
.
ToLower
(
strings
.
TrimSpace
(
string
(
out
)))
}
out
,
err
=
exec
.
Command
(
"uname"
,
"-r"
)
.
Output
()
if
err
==
nil
{
ret
.
PlatformVersion
=
strings
.
ToLower
(
strings
.
TrimSpace
(
string
(
out
)))
}
values
,
err
:=
doSysctrl
(
"kern.boottime"
)
if
err
==
nil
{
// ex: { sec = 1392261637, usec = 627534 } Thu Feb 13 12:20:37 2014
v
:=
strings
.
Replace
(
values
[
2
],
","
,
""
,
1
)
ret
.
Uptime
=
mustParseUint64
(
v
)
}
return
ret
,
nil
}
...
...
host_linux.go
浏览文件 @
f5a85e6b
...
...
@@ -38,16 +38,20 @@ func HostInfo() (*HostInfoStat, error) {
ret
.
PlatformFamily
=
family
ret
.
PlatformVersion
=
version
}
uptime
,
err
:=
BootTime
()
if
err
==
nil
{
ret
.
Uptime
=
uptime
}
return
ret
,
nil
}
func
BootTime
()
(
int64
,
error
)
{
func
BootTime
()
(
u
int64
,
error
)
{
sysinfo
:=
&
syscall
.
Sysinfo_t
{}
if
err
:=
syscall
.
Sysinfo
(
sysinfo
);
err
!=
nil
{
return
0
,
err
}
return
int64
(
sysinfo
.
Uptime
),
nil
return
u
int64
(
sysinfo
.
Uptime
),
nil
}
func
Users
()
([]
UserStat
,
error
)
{
...
...
host_windows.go
浏览文件 @
f5a85e6b
...
...
@@ -26,7 +26,7 @@ func HostInfo() (*HostInfoStat, error) {
return
ret
,
syscall
.
GetLastError
()
}
ret
.
Uptime
=
int64
(
uptimemsec
)
/
1000
ret
.
Uptime
=
u
int64
(
uptimemsec
)
/
1000
procs
,
err
:=
Pids
()
if
err
!=
nil
{
...
...
@@ -38,7 +38,7 @@ func HostInfo() (*HostInfoStat, error) {
return
ret
,
nil
}
func
BootTime
()
(
int64
,
error
)
{
func
BootTime
()
(
u
int64
,
error
)
{
var
lpSystemTimeAsFileTime
FILETIME
r
,
_
,
_
:=
procGetSystemTimeAsFileTime
.
Call
(
uintptr
(
unsafe
.
Pointer
(
&
lpSystemTimeAsFileTime
)))
...
...
@@ -56,7 +56,7 @@ func BootTime() (int64, error) {
}
uptime
:=
uint64
(
u
)
/
1000
return
int64
(
pt
-
uptime
),
nil
return
u
int64
(
pt
-
uptime
),
nil
}
func
Users
()
([]
UserStat
,
error
)
{
...
...
mem_freebsd.go
浏览文件 @
f5a85e6b
...
...
@@ -10,7 +10,7 @@ import (
func
VirtualMemory
()
(
*
VirtualMemoryStat
,
error
)
{
pageSize
,
_
:=
doSysctrl
(
"vm.stats.vm.v_page_size"
)
p
:=
p
arseUint64
(
pageSize
[
0
])
p
:=
mustP
arseUint64
(
pageSize
[
0
])
pageCount
,
_
:=
doSysctrl
(
"vm.stats.vm.v_page_count"
)
free
,
_
:=
doSysctrl
(
"vm.stats.vm.v_free_count"
)
...
...
@@ -21,13 +21,13 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
wired
,
_
:=
doSysctrl
(
"vm.stats.vm.v_wire_count"
)
ret
:=
&
VirtualMemoryStat
{
Total
:
p
arseUint64
(
pageCount
[
0
])
*
p
,
Free
:
p
arseUint64
(
free
[
0
])
*
p
,
Active
:
p
arseUint64
(
active
[
0
])
*
p
,
Inactive
:
p
arseUint64
(
inactive
[
0
])
*
p
,
Cached
:
p
arseUint64
(
cache
[
0
])
*
p
,
Buffers
:
p
arseUint64
(
buffer
[
0
]),
Wired
:
p
arseUint64
(
wired
[
0
])
*
p
,
Total
:
mustP
arseUint64
(
pageCount
[
0
])
*
p
,
Free
:
mustP
arseUint64
(
free
[
0
])
*
p
,
Active
:
mustP
arseUint64
(
active
[
0
])
*
p
,
Inactive
:
mustP
arseUint64
(
inactive
[
0
])
*
p
,
Cached
:
mustP
arseUint64
(
cache
[
0
])
*
p
,
Buffers
:
mustP
arseUint64
(
buffer
[
0
]),
Wired
:
mustP
arseUint64
(
wired
[
0
])
*
p
,
}
// TODO: platform independent (worked freebsd?)
...
...
@@ -57,10 +57,10 @@ func SwapMemory() (*SwapMemoryStat, error) {
u
:=
strings
.
Replace
(
values
[
4
],
"%"
,
""
,
1
)
ret
=
&
SwapMemoryStat
{
Total
:
p
arseUint64
(
values
[
1
]),
Used
:
p
arseUint64
(
values
[
2
]),
Free
:
p
arseUint64
(
values
[
3
]),
UsedPercent
:
p
arseFloat64
(
u
),
Total
:
mustP
arseUint64
(
values
[
1
]),
Used
:
mustP
arseUint64
(
values
[
2
]),
Free
:
mustP
arseUint64
(
values
[
3
]),
UsedPercent
:
mustP
arseFloat64
(
u
),
}
}
...
...
net_freebsd.go
浏览文件 @
f5a85e6b
...
...
@@ -3,9 +3,43 @@
package
gopsutil
import
(
"errors"
"os/exec"
"strings"
)
func
NetIOCounters
(
pernic
bool
)
([]
NetIOCountersStat
,
error
)
{
return
nil
,
errors
.
New
(
"not implemented yet"
)
out
,
err
:=
exec
.
Command
(
"/usr/bin/netstat"
,
"-ibdn"
)
.
Output
()
if
err
!=
nil
{
return
nil
,
err
}
lines
:=
strings
.
Split
(
string
(
out
),
"
\n
"
)
ret
:=
make
([]
NetIOCountersStat
,
0
,
len
(
lines
)
-
1
)
for
_
,
line
:=
range
lines
{
values
:=
strings
.
Fields
(
line
)
if
len
(
values
)
<
1
||
values
[
0
]
==
"Name"
{
continue
}
base
:=
1
// sometimes Address is ommitted
if
len
(
values
)
<
13
{
base
=
0
}
n
:=
NetIOCountersStat
{
Name
:
values
[
0
],
PacketsRecv
:
mustParseUint64
(
values
[
base
+
3
]),
Errin
:
mustParseUint64
(
values
[
base
+
4
]),
Dropin
:
mustParseUint64
(
values
[
base
+
5
]),
BytesRecv
:
mustParseUint64
(
values
[
base
+
6
]),
PacketsSent
:
mustParseUint64
(
values
[
base
+
7
]),
Errout
:
mustParseUint64
(
values
[
base
+
8
]),
BytesSent
:
mustParseUint64
(
values
[
base
+
9
]),
Dropout
:
mustParseUint64
(
values
[
base
+
11
]),
}
ret
=
append
(
ret
,
n
)
}
return
ret
,
nil
}
net_linux.go
浏览文件 @
f5a85e6b
...
...
@@ -24,13 +24,13 @@ func NetIOCounters(pernic bool) ([]NetIOCountersStat, error) {
}
nic
:=
NetIOCountersStat
{
Name
:
strings
.
Trim
(
fields
[
0
],
":"
),
BytesRecv
:
p
arseUint64
(
fields
[
1
]),
Errin
:
p
arseUint64
(
fields
[
2
]),
Dropin
:
p
arseUint64
(
fields
[
3
]),
BytesSent
:
p
arseUint64
(
fields
[
9
]),
PacketsSent
:
p
arseUint64
(
fields
[
10
]),
Errout
:
p
arseUint64
(
fields
[
11
]),
Dropout
:
p
arseUint64
(
fields
[
12
]),
BytesRecv
:
mustP
arseUint64
(
fields
[
1
]),
Errin
:
mustP
arseUint64
(
fields
[
2
]),
Dropin
:
mustP
arseUint64
(
fields
[
3
]),
BytesSent
:
mustP
arseUint64
(
fields
[
9
]),
PacketsSent
:
mustP
arseUint64
(
fields
[
10
]),
Errout
:
mustP
arseUint64
(
fields
[
11
]),
Dropout
:
mustP
arseUint64
(
fields
[
12
]),
}
ret
=
append
(
ret
,
nic
)
}
...
...
process_linux.go
浏览文件 @
f5a85e6b
...
...
@@ -234,25 +234,25 @@ func (p *Process) MemoryMaps(grouped bool) (*[]MemoryMapsStat, error) {
v
:=
strings
.
Trim
(
field
[
1
],
" kB"
)
// remove last "kB"
switch
field
[
0
]
{
case
"Size"
:
m
.
Size
=
p
arseUint64
(
v
)
m
.
Size
=
mustP
arseUint64
(
v
)
case
"Rss"
:
m
.
Rss
=
p
arseUint64
(
v
)
m
.
Rss
=
mustP
arseUint64
(
v
)
case
"Pss"
:
m
.
Pss
=
p
arseUint64
(
v
)
m
.
Pss
=
mustP
arseUint64
(
v
)
case
"Shared_Clean"
:
m
.
SharedClean
=
p
arseUint64
(
v
)
m
.
SharedClean
=
mustP
arseUint64
(
v
)
case
"Shared_Dirty"
:
m
.
SharedDirty
=
p
arseUint64
(
v
)
m
.
SharedDirty
=
mustP
arseUint64
(
v
)
case
"Private_Clean"
:
m
.
PrivateClean
=
p
arseUint64
(
v
)
m
.
PrivateClean
=
mustP
arseUint64
(
v
)
case
"Private_Dirty"
:
m
.
PrivateDirty
=
p
arseUint64
(
v
)
m
.
PrivateDirty
=
mustP
arseUint64
(
v
)
case
"Referenced"
:
m
.
Referenced
=
p
arseUint64
(
v
)
m
.
Referenced
=
mustP
arseUint64
(
v
)
case
"Anonymous"
:
m
.
Anonymous
=
p
arseUint64
(
v
)
m
.
Anonymous
=
mustP
arseUint64
(
v
)
case
"Swap"
:
m
.
Swap
=
p
arseUint64
(
v
)
m
.
Swap
=
mustP
arseUint64
(
v
)
}
}
return
m
...
...
@@ -301,7 +301,7 @@ func (p *Process) fillFromfd() (int32, []*OpenFilesStat, error) {
}
o
:=
&
OpenFilesStat
{
Path
:
filepath
,
Fd
:
p
arseUint64
(
fd
),
Fd
:
mustP
arseUint64
(
fd
),
}
openfiles
=
append
(
openfiles
,
o
)
}
...
...
@@ -368,13 +368,13 @@ func (p *Process) fillFromIO() (*IOCountersStat, error) {
}
switch
field
[
0
]
{
case
"rchar"
:
ret
.
ReadCount
=
p
arseInt32
(
strings
.
Trim
(
field
[
1
],
"
\t
"
))
ret
.
ReadCount
=
mustP
arseInt32
(
strings
.
Trim
(
field
[
1
],
"
\t
"
))
case
"wchar"
:
ret
.
WriteCount
=
p
arseInt32
(
strings
.
Trim
(
field
[
1
],
"
\t
"
))
ret
.
WriteCount
=
mustP
arseInt32
(
strings
.
Trim
(
field
[
1
],
"
\t
"
))
case
"read_bytes"
:
ret
.
ReadBytes
=
p
arseInt32
(
strings
.
Trim
(
field
[
1
],
"
\t
"
))
ret
.
ReadBytes
=
mustP
arseInt32
(
strings
.
Trim
(
field
[
1
],
"
\t
"
))
case
"write_bytes"
:
ret
.
WriteBytes
=
p
arseInt32
(
strings
.
Trim
(
field
[
1
],
"
\t
"
))
ret
.
WriteBytes
=
mustP
arseInt32
(
strings
.
Trim
(
field
[
1
],
"
\t
"
))
}
}
...
...
@@ -391,8 +391,8 @@ func (p *Process) fillFromStatm() (*MemoryInfoStat, *MemoryInfoExStat, error) {
}
fields
:=
strings
.
Split
(
string
(
contents
),
" "
)
rss
:=
p
arseUint64
(
fields
[
0
])
*
PAGESIZE
vms
:=
p
arseUint64
(
fields
[
1
])
*
PAGESIZE
rss
:=
mustP
arseUint64
(
fields
[
0
])
*
PAGESIZE
vms
:=
mustP
arseUint64
(
fields
[
1
])
*
PAGESIZE
memInfo
:=
&
MemoryInfoStat
{
RSS
:
rss
,
VMS
:
vms
,
...
...
@@ -400,10 +400,10 @@ func (p *Process) fillFromStatm() (*MemoryInfoStat, *MemoryInfoExStat, error) {
memInfoEx
:=
&
MemoryInfoExStat
{
RSS
:
rss
,
VMS
:
vms
,
Shared
:
p
arseUint64
(
fields
[
2
])
*
PAGESIZE
,
Text
:
p
arseUint64
(
fields
[
3
])
*
PAGESIZE
,
Lib
:
p
arseUint64
(
fields
[
4
])
*
PAGESIZE
,
Dirty
:
p
arseUint64
(
fields
[
5
])
*
PAGESIZE
,
Shared
:
mustP
arseUint64
(
fields
[
2
])
*
PAGESIZE
,
Text
:
mustP
arseUint64
(
fields
[
3
])
*
PAGESIZE
,
Lib
:
mustP
arseUint64
(
fields
[
4
])
*
PAGESIZE
,
Dirty
:
mustP
arseUint64
(
fields
[
5
])
*
PAGESIZE
,
}
return
memInfo
,
memInfoEx
,
nil
...
...
@@ -443,18 +443,18 @@ func (p *Process) fillFromStatus() (string, string, []int32, []int32, int32, *Nu
// case "PPid": // filled by fillFromStat
case
"Uid"
:
for
_
,
i
:=
range
strings
.
Split
(
field
[
1
],
"
\t
"
)
{
uids
=
append
(
uids
,
p
arseInt32
(
i
))
uids
=
append
(
uids
,
mustP
arseInt32
(
i
))
}
case
"Gid"
:
for
_
,
i
:=
range
strings
.
Split
(
field
[
1
],
"
\t
"
)
{
gids
=
append
(
gids
,
p
arseInt32
(
i
))
gids
=
append
(
gids
,
mustP
arseInt32
(
i
))
}
case
"Threads"
:
numThreads
=
p
arseInt32
(
field
[
1
])
numThreads
=
mustP
arseInt32
(
field
[
1
])
case
"voluntary_ctxt_switches"
:
vol
=
p
arseInt32
(
field
[
1
])
vol
=
mustP
arseInt32
(
field
[
1
])
case
"nonvoluntary_ctxt_switches"
:
unvol
=
p
arseInt32
(
field
[
1
])
unvol
=
mustP
arseInt32
(
field
[
1
])
}
}
...
...
@@ -477,10 +477,10 @@ func (p *Process) fillFromStat() (string, int32, *CPUTimesStat, int64, int32, er
termmap
,
err
:=
getTerminalMap
()
terminal
:=
""
if
err
==
nil
{
terminal
=
termmap
[
p
arseUint64
(
fields
[
6
])]
terminal
=
termmap
[
mustP
arseUint64
(
fields
[
6
])]
}
ppid
:=
p
arseInt32
(
fields
[
3
])
ppid
:=
mustP
arseInt32
(
fields
[
3
])
utime
,
_
:=
strconv
.
ParseFloat
(
fields
[
13
],
64
)
stime
,
_
:=
strconv
.
ParseFloat
(
fields
[
14
],
64
)
...
...
@@ -491,10 +491,10 @@ func (p *Process) fillFromStat() (string, int32, *CPUTimesStat, int64, int32, er
}
bootTime
,
_
:=
BootTime
()
ctime
:=
((
p
arseUint64
(
fields
[
21
])
/
uint64
(
CLOCK_TICKS
))
+
uint64
(
bootTime
))
*
1000
ctime
:=
((
mustP
arseUint64
(
fields
[
21
])
/
uint64
(
CLOCK_TICKS
))
+
uint64
(
bootTime
))
*
1000
createTime
:=
int64
(
ctime
)
// p.Nice =
p
arseInt32(fields[18])
// p.Nice =
mustP
arseInt32(fields[18])
// use syscall instead of parse Stat file
snice
,
_
:=
syscall
.
Getpriority
(
PRIO_PROCESS
,
int
(
pid
))
nice
:=
int32
(
snice
)
// FIXME: is this true?
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录