-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
config.go
81 lines (61 loc) · 2.77 KB
/
config.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
package ebpf
import (
"strings"
aconfig "github.com/DataDog/datadog-agent/pkg/config"
"github.com/DataDog/datadog-agent/pkg/process/util"
)
const (
spNS = "system_probe_config"
)
// Config stores all common flags used by system-probe
type Config struct {
// BPFDebug enables bpf debug logs
BPFDebug bool
// BPFDir is the directory to load the eBPF program from
BPFDir string
// ExcludedBPFLinuxVersions lists Linux kernel versions that should not use BPF features
ExcludedBPFLinuxVersions []string
// ProcRoot is the root path to the proc filesystem
ProcRoot string
// EnableTracepoints enables use of tracepoints instead of kprobes for probing syscalls (if available on system)
EnableTracepoints bool
// EnableRuntimeCompiler enables the use of the embedded compiler to build eBPF programs on-host
EnableRuntimeCompiler bool
// KernelHeadersDir is the directories of the kernel headers to use for runtime compilation
KernelHeadersDirs []string
// KernelHeadersDownloadDir is the directory where the system-probe will attempt to download kernel headers, if necessary
KernelHeadersDownloadDir string
// RuntimeCompilerOutputDir is the directory where the runtime compiler will store compiled programs
RuntimeCompilerOutputDir string
// AptConfigDir is the path to the apt config directory
AptConfigDir string
// YumReposDir is the path to the yum repository directory
YumReposDir string
// ZypperReposDir is the path to the zypper repository directory
ZypperReposDir string
// AllowPrecompiledFallback indicates whether we are allowed to fallback to the prebuilt probes if runtime compilation fails.
AllowPrecompiledFallback bool
}
func key(pieces ...string) string {
return strings.Join(pieces, ".")
}
// NewConfig creates a config with ebpf-related settings
func NewConfig() *Config {
cfg := aconfig.Datadog
aconfig.InitSystemProbeConfig(cfg)
return &Config{
BPFDebug: cfg.GetBool(key(spNS, "bpf_debug")),
BPFDir: cfg.GetString(key(spNS, "bpf_dir")),
ExcludedBPFLinuxVersions: cfg.GetStringSlice(key(spNS, "excluded_linux_versions")),
EnableTracepoints: cfg.GetBool(key(spNS, "enable_tracepoints")),
ProcRoot: util.GetProcRoot(),
EnableRuntimeCompiler: cfg.GetBool(key(spNS, "enable_runtime_compiler")),
RuntimeCompilerOutputDir: cfg.GetString(key(spNS, "runtime_compiler_output_dir")),
KernelHeadersDirs: cfg.GetStringSlice(key(spNS, "kernel_header_dirs")),
KernelHeadersDownloadDir: cfg.GetString(key(spNS, "kernel_header_download_dir")),
AptConfigDir: cfg.GetString(key(spNS, "apt_config_dir")),
YumReposDir: cfg.GetString(key(spNS, "yum_repos_dir")),
ZypperReposDir: cfg.GetString(key(spNS, "zypper_repos_dir")),
AllowPrecompiledFallback: true,
}
}