-
Notifications
You must be signed in to change notification settings - Fork 93
/
hostcollector_shared.go
234 lines (205 loc) · 10.3 KB
/
hostcollector_shared.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
package v1beta2
import (
"github.com/replicatedhq/troubleshoot/pkg/multitype"
)
type HostCollectorMeta struct {
CollectorName string `json:"collectorName,omitempty" yaml:"collectorName,omitempty"`
// +optional
Exclude *multitype.BoolOrString `json:"exclude,omitempty" yaml:"exclude,omitempty"`
}
type CPU struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type Memory struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type TCPLoadBalancer struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Address string `json:"address"`
Port int `json:"port"`
Timeout string `json:"timeout,omitempty"`
}
type HTTPLoadBalancer struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Address string `json:"address"`
Port int `json:"port"`
Path string `json:"path"`
Timeout string `json:"timeout,omitempty"`
}
type TCPPortStatus struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Interface string `json:"interface,omitempty"`
Port int `json:"port"`
}
type UDPPortStatus struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Interface string `json:"interface,omitempty"`
Port int `json:"port"`
}
type Kubernetes struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type IPV4Interfaces struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type SubnetAvailable struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
CIDRRangeAlloc string `json:"CIDRRangeAlloc" yaml:"CIDRRangeAlloc"`
DesiredCIDR int `json:"desiredCIDR" yaml:"desiredCIDR"`
}
type DiskUsage struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Path string `json:"path" yaml:"path"`
}
type HostHTTP struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Get *Get `json:"get,omitempty" yaml:"get,omitempty"`
Post *Post `json:"post,omitempty" yaml:"post,omitempty"`
Put *Put `json:"put,omitempty" yaml:"put,omitempty"`
}
type HostCopy struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Path string `json:"path" yaml:"path"`
}
type HostTime struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type HostBlockDevices struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type HostSystemPackages struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Ubuntu []string `json:"ubuntu,omitempty"`
Ubuntu16 []string `json:"ubuntu16,omitempty"`
Ubuntu18 []string `json:"ubuntu18,omitempty"`
Ubuntu20 []string `json:"ubuntu20,omitempty"`
RHEL []string `json:"rhel,omitempty"`
RHEL7 []string `json:"rhel7,omitempty"`
RHEL8 []string `json:"rhel8,omitempty"`
RHEL9 []string `json:"rhel9,omitempty"`
RockyLinux []string `json:"rocky,omitempty"`
RockyLinux8 []string `json:"rocky8,omitempty"`
RockyLinux9 []string `json:"rocky9,omitempty"`
CentOS []string `json:"centos,omitempty"`
CentOS7 []string `json:"centos7,omitempty"`
CentOS8 []string `json:"centos8,omitempty"`
CentOS9 []string `json:"centos9,omitempty"`
OracleLinux []string `json:"ol,omitempty"`
OracleLinux7 []string `json:"ol7,omitempty"`
OracleLinux8 []string `json:"ol8,omitempty"`
OracleLinux9 []string `json:"ol9,omitempty"`
AmazonLinux []string `json:"amzn,omitempty"`
AmazonLinux2 []string `json:"amzn2,omitempty"`
}
type HostKernelModules struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type HostOS struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type TCPConnect struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Address string `json:"address"`
Timeout string `json:"timeout,omitempty"`
}
// FilesystemPerformance benchmarks sequential write latency on a single file.
// The optional background IOPS feature attempts to mimic real-world conditions by running read and
// write workloads prior to and during benchmark execution.
type FilesystemPerformance struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
// The size of each write operation performed while benchmarking. This does not apply to the
// background IOPS feature if enabled, since those must be fixed at 4096.
OperationSizeBytes uint64 `json:"operationSize,omitempty"`
// The directory where the benchmark will create files.
Directory string `json:"directory,omitempty"`
// The size of the file used in the benchmark. The number of IO operations for the benchmark
// will be FileSize / OperationSizeBytes. Accepts valid Kubernetes resource units such as Mi.
FileSize string `json:"fileSize,omitempty"`
// Whether to call sync on the file after each write. Does not apply to background IOPS task.
Sync bool `json:"sync,omitempty"`
// Whether to call datasync on the file after each write. Skipped if Sync is also true. Does not
// apply to background IOPS task.
Datasync bool `json:"datasync,omitempty"`
// Total timeout, including background IOPS setup and warmup if enabled.
Timeout string `json:"timeout,omitempty"`
// Enable the background IOPS feature.
EnableBackgroundIOPS bool `json:"enableBackgroundIOPS"`
// How long to run the background IOPS read and write workloads prior to starting the benchmarks.
BackgroundIOPSWarmupSeconds int `json:"backgroundIOPSWarmupSeconds"`
// The target write IOPS to run while benchmarking. This is a limit and there is no guarantee
// it will be reached. This is the total IOPS for all background write jobs.
BackgroundWriteIOPS int `json:"backgroundWriteIOPS"`
// The target read IOPS to run while benchmarking. This is a limit and there is no guarantee
// it will be reached. This is the total IOPS for all background read jobs.
BackgroundReadIOPS int `json:"backgroundReadIOPS"`
// Number of threads to use for background write IOPS. This should be set high enough to reach
// the target specified in BackgroundWriteIOPS.
// Example: If BackgroundWriteIOPS is 100 and write latency is 10ms then a single job would
// barely be able to reach 100 IOPS so this should be at least 2.
BackgroundWriteIOPSJobs int `json:"backgroundWriteIOPSJobs"`
// Number of threads to use for background read IOPS. This should be set high enough to reach
// the target specified in BackgrounReadIOPS.
BackgroundReadIOPSJobs int `json:"backgroundReadIOPSJobs"`
}
type Certificate struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
CertificatePath string `json:"certificatePath" yaml:"certificatepath"`
KeyPath string `json:"keyPath" yaml:"keyPath"`
}
type HostCertificatesCollection struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Paths []string `json:"paths" yaml:"paths"`
}
type HostServices struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
}
type HostRun struct {
HostCollectorMeta `json:",inline" yaml:",inline"`
Command string `json:"command"`
Args []string `json:"args"`
OutputDir string `json:"outputDir,omitempty" yaml:"outputDir,omitempty"`
Input map[string]string `json:"input,omitempty" yaml:"input,omitempty"`
Env []string `json:"env,omitempty" yaml:"env,omitempty"`
InheritEnvs []string `json:"inheritEnvs,omitempty" yaml:"inheritEnvs,omitempty"`
IgnoreParentEnvs bool `json:"ignoreParentEnvs,omitempty" yaml:"ignoreParentEnvs,omitempty"`
Timeout string `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}
type HostCollect struct {
CPU *CPU `json:"cpu,omitempty" yaml:"cpu,omitempty"`
Memory *Memory `json:"memory,omitempty" yaml:"memory,omitempty"`
TCPLoadBalancer *TCPLoadBalancer `json:"tcpLoadBalancer,omitempty" yaml:"tcpLoadBalancer,omitempty"`
HTTPLoadBalancer *HTTPLoadBalancer `json:"httpLoadBalancer,omitempty" yaml:"httpLoadBalancer,omitempty"`
TCPPortStatus *TCPPortStatus `json:"tcpPortStatus,omitempty" yaml:"tcpPortStatus,omitempty"`
UDPPortStatus *UDPPortStatus `json:"udpPortStatus,omitempty" yaml:"udpPortStatus,omitempty"`
Kubernetes *Kubernetes `json:"kubernetes,omitempty" yaml:"kubernetes,omitempty"`
IPV4Interfaces *IPV4Interfaces `json:"ipv4Interfaces,omitempty" yaml:"ipv4Interfaces,omitempty"`
SubnetAvailable *SubnetAvailable `json:"subnetAvailable,omitempty" yaml:"subnetAvailable,omitempty"`
DiskUsage *DiskUsage `json:"diskUsage,omitempty" yaml:"diskUsage,omitempty"`
HTTP *HostHTTP `json:"http,omitempty" yaml:"http,omitempty"`
Time *HostTime `json:"time,omitempty" yaml:"time,omitempty"`
BlockDevices *HostBlockDevices `json:"blockDevices,omitempty" yaml:"blockDevices,omitempty"`
SystemPackages *HostSystemPackages `json:"systemPackages,omitempty" yaml:"systemPackages,omitempty"`
KernelModules *HostKernelModules `json:"kernelModules,omitempty" yaml:"kernelModules,omitempty"`
TCPConnect *TCPConnect `json:"tcpConnect,omitempty" yaml:"tcpConnect,omitempty"`
FilesystemPerformance *FilesystemPerformance `json:"filesystemPerformance,omitempty" yaml:"filesystemPerformance,omitempty"`
Certificate *Certificate `json:"certificate,omitempty" yaml:"certificate,omitempty"`
CertificatesCollection *HostCertificatesCollection `json:"certificatesCollection,omitempty" yaml:"certificatesCollection,omitempty"`
HostServices *HostServices `json:"hostServices,omitempty" yaml:"hostServices,omitempty"`
HostOS *HostOS `json:"hostOS,omitempty" yaml:"hostOS,omitempty"`
HostRun *HostRun `json:"run,omitempty" yaml:"run,omitempty"`
HostCopy *HostCopy `json:"copy,omitempty" yaml:"copy,omitempty"`
}
func (c *HostCollect) GetName() string {
// TODO: Is this used anywhere? Should we just remove it?
var collector string
if c.CPU != nil {
collector = "cpu"
}
if c.Memory != nil {
collector = "memory"
}
if collector == "" {
return "<none>"
}
return collector
}