forked from chaolihf/OneAgent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOneAgent_test.go
More file actions
60 lines (56 loc) · 1.5 KB
/
OneAgent_test.go
File metadata and controls
60 lines (56 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package main
import (
"fmt"
"testing"
process "github.com/chaolihf/gopsutil/process"
node_expoter_main "github.com/chaolihf/node_exporter"
)
// 包引用是包含模块名/路径名/包名
func TestNodeExpoterModule(t *testing.T) {
node_expoter_main.Main()
}
func TestPsModule(t *testing.T) {
allProcess, err := process.Processes()
if err != nil {
logger.Error(err.Error())
return
} else {
for _, item := range allProcess {
nsPid, _ := item.GetNamespacePid()
fmt.Println(nsPid)
username, _ := item.Username()
fmt.Println(username)
name, _ := item.Name()
fmt.Println(name)
command, _ := item.Cmdline()
fmt.Println(command)
memory, _ := item.MemoryInfo()
fmt.Println(memory)
numThread, _ := item.NumThreads()
fmt.Println(numThread)
numOpenFiles, _ := item.NumFDs()
fmt.Println(numOpenFiles)
createTime, _ := item.CreateTime()
fmt.Println(createTime)
parentId, _ := item.Ppid()
fmt.Println(parentId)
cpu, _ := item.CPUPercent()
fmt.Println(cpu)
exec, _ := item.Exe()
fmt.Println(exec)
ioCounters, _ := item.IOCounters()
fmt.Println(ioCounters)
if memory != nil {
fmt.Println(int64(memory.RSS))
fmt.Println(int64(memory.VMS))
}
fmt.Println(item.Pid)
if ioCounters != nil {
fmt.Println(int64(ioCounters.ReadBytes))
fmt.Println(int64(ioCounters.WriteBytes))
fmt.Println(int64(ioCounters.ReadCount))
fmt.Println(int64(ioCounters.WriteCount))
}
}
}
}