-
Notifications
You must be signed in to change notification settings - Fork 39
/
traffic_dump.go
86 lines (74 loc) · 2.2 KB
/
traffic_dump.go
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package serv
type MemInfo struct {
MemTotal uint64 `json:"mem_total"`
MemFree uint64 `json:"mem_free"`
MemUsed uint64 `json:"mem_used"`
MemUsedPercent float64 `json:"mem_used_percent"`
}
func NewMemInfo(memTotal uint64, memFree uint64, memUsed uint64, memUsedPercent float64) MemInfo {
return MemInfo{
MemTotal: memTotal,
MemFree: memFree,
MemUsed: memUsed,
MemUsedPercent: memUsedPercent,
}
}
type SingleCpuInfo struct {
CpuModelName string `json:"cpu_model_name"`
CpuCores int32 `json:"cpu_cores"`
}
func NewSingleCpuInfo(cpuModelName string, cpuCores int32) SingleCpuInfo {
return SingleCpuInfo{
CpuModelName: cpuModelName,
CpuCores: cpuCores,
}
}
type CpuInfo struct {
CpuInfos []SingleCpuInfo `json:"cpu_infos"`
CpuUsedPercent float64 `json:"cpu_used_percent"`
}
func NewCpuInfo(cpuInfos []SingleCpuInfo, cpuUsedPercent float64) CpuInfo {
return CpuInfo{
CpuInfos: cpuInfos,
CpuUsedPercent: cpuUsedPercent,
}
}
type HdInfo struct {
HdTotal uint64 `json:"hd_total"`
HdFree uint64 `json:"hd_free"`
HdUsed uint64 `json:"hd_used"`
HdUsedPercent float64 `json:"hd_used_percent"`
}
func NewHdInfo(hdTotal uint64, hdFree uint64, hdUsed uint64, hdUsedPercent float64) HdInfo {
return HdInfo{
HdTotal: hdTotal,
HdFree: hdFree,
HdUsed: hdUsed,
HdUsedPercent: hdUsedPercent,
}
}
type TrafficInfo struct {
TrafficInbound uint64 `json:"traffic_inbound"`
TrafficOutbound uint64 `json:"traffic_outbound"`
TimeStamp string `json:"time_stamp,omitempty"`
}
func NewTrafficInfo(trafficInbound uint64, trafficOutbound uint64) TrafficInfo {
return TrafficInfo{
TrafficInbound: trafficInbound,
TrafficOutbound: trafficOutbound,
}
}
type TrafficDumpInfo struct {
MemInfo MemInfo `json:"mem_info"`
CpuInfo CpuInfo `json:"cpu_info"`
HdInfo HdInfo `json:"hd_info"`
TrafficInfo TrafficInfo `json:"traffic_info"`
}
func NewTrafficDumpInfo(memInfo MemInfo, cpuInfo CpuInfo, hdInfo HdInfo, trafficInfo TrafficInfo) TrafficDumpInfo {
return TrafficDumpInfo{
MemInfo: memInfo,
CpuInfo: cpuInfo,
HdInfo: hdInfo,
TrafficInfo: trafficInfo,
}
}