/
agent.go
114 lines (98 loc) · 2.25 KB
/
agent.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
package model
import (
"fmt"
)
type AgentReportRequest struct {
Hostname string
IP string
AgentVersion string
PluginVersion string
GitRepo string
}
func (this *AgentReportRequest) String() string {
return fmt.Sprintf(
"<Hostname:%s, IP:%s, AgentVersion:%s, PluginVersion:%s, GitRepo: %s>",
this.Hostname,
this.IP,
this.AgentVersion,
this.PluginVersion,
this.GitRepo,
)
}
type AgentUpdateInfo struct {
LastUpdate int64
ReportRequest *AgentReportRequest
}
type AgentHeartbeatRequest struct {
Hostname string
Checksum string
}
func (this *AgentHeartbeatRequest) String() string {
return fmt.Sprintf(
"<Hostname: %s, Checksum: %s>",
this.Hostname,
this.Checksum,
)
}
type AgentPluginsResponse struct {
Plugins []string
Timestamp int64
GitRepo string
GitUpdate bool
GitRepoUpdate bool
}
func (this *AgentPluginsResponse) String() string {
return fmt.Sprintf(
"<Plugins:%v, Timestamp:%v, GitRepo:%v, GitUpdate:%v, GitRepoUpdate:%v>",
this.Plugins,
this.Timestamp,
this.GitRepo,
this.GitUpdate,
this.GitRepoUpdate,
)
}
// e.g. net.port.listen or proc.num
type BuiltinMetric struct {
Metric string
Tags string
}
func (this *BuiltinMetric) String() string {
return fmt.Sprintf(
"%s/%s",
this.Metric,
this.Tags,
)
}
type BuiltinMetricResponse struct {
Metrics []*BuiltinMetric
Checksum string
Timestamp int64
}
func (this *BuiltinMetricResponse) String() string {
return fmt.Sprintf(
"<Metrics:%v, Checksum:%s, Timestamp:%v>",
this.Metrics,
this.Checksum,
this.Timestamp,
)
}
type BuiltinMetricSlice []*BuiltinMetric
func (this BuiltinMetricSlice) Len() int {
return len(this)
}
func (this BuiltinMetricSlice) Swap(i, j int) {
this[i], this[j] = this[j], this[i]
}
func (this BuiltinMetricSlice) Less(i, j int) bool {
return this[i].String() < this[j].String()
}
type FalconAgentHeartbeat struct {
Hostname string `json:"hostname" conform:"trim"`
IP string `json:"ip" conform:"trim"`
AgentVersion string `json:"agent_version" conform:"trim"`
PluginVersion string `json:"plugin_version" conform:"trim"`
UpdateTime int64 `json:"update_time" conform:"trim"`
}
type FalconAgentHeartbeatResult struct {
RowsAffected int64 `json:"rows_affected"`
}