-
Notifications
You must be signed in to change notification settings - Fork 149
Expand file tree
/
Copy pathconfig_windows.go
More file actions
105 lines (89 loc) · 2.69 KB
/
config_windows.go
File metadata and controls
105 lines (89 loc) · 2.69 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
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
// Copyright 2020 New Relic Corporation. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
package config
import (
"os"
"os/user"
"path/filepath"
"github.com/kelseyhightower/envconfig"
)
const (
defaultAppDataSubDir = "New Relic" + string(filepath.Separator) + "newrelic-infra"
defaultConnectEnabled = true
)
func init() {
defaultNetworkInterfaceFilters = map[string][]string{
"prefix": {"Loop", "isatap"},
}
// NOTE: On Windows, we need at least ComSpec for the agent to be able to run batch files
// and SystemRoot for the integration to be able to use the networking layer in some libraries.
// default Windows global environment variables excluding particulars to user
defaultPassthroughEnvironment = []string{
"ALLUSERSPROFILE",
"APPDATA",
"CommonProgramFiles",
"CommonProgramFiles(x86)",
"CommonProgramW6432",
"COMPUTERNAME",
"ComSpec",
"LOCALAPPDATA",
"Path",
"PATH",
"PATHEXT",
"ProgramData",
"ProgramFiles",
"ProgramFiles(x86)",
"ProgramW6432",
"PSModulePath",
"SystemDrive",
"SystemRoot",
"TEMP",
"TMP",
"windir",
}
programData := os.Getenv("ProgramData")
defaultAppDataDir = filepath.Join(programData, defaultAppDataSubDir)
defaultAgentDir = filepath.Join(os.Getenv("ProgramFiles"), "New Relic", "newrelic-infra")
defaultSafeBinDir = defaultAgentDir
defaultConfigDir = defaultAgentDir
defaultLogFile = filepath.Join(defaultAgentDir, "newrelic-infra.log")
defaultPluginInstanceDir = filepath.Join(defaultAgentDir, "integrations.d")
defaultConfigFiles = []string{filepath.Join(defaultAgentDir, "newrelic-infra.yml")}
defaultPluginConfigFiles = []string{filepath.Join(defaultAgentDir, "newrelic-infra-plugins.yml")}
defaultLoggingHomeDir = "logging"
defaultLoggingConfigsDir = "logging.d"
defaultFluentBitParsers = "parsers.conf"
defaultFluentBitNRLib = "out_newrelic.dll"
defaultAgentTempDir = filepath.Join(defaultAppDataDir, agentTemporaryFolderName)
}
func runtimeValues() (userMode, agentUser, executablePath string) {
userMode = ModeRoot
usr, err := user.Current()
if err != nil {
clog.WithError(err).Warn("unable to fetch current user")
}
if usr != nil {
agentUser = usr.Username
}
executablePath, err = os.Executable()
if err != nil {
clog.WithError(err).Warn("unable to fetch the agent executable path")
}
return
}
func configOverride(cfg *Config) {
if err := envconfig.Process(envPrefix, cfg); err != nil {
clog.WithError(err).Error("unable to interpret environment variables")
}
}
func loadDefaultLogRotation() LogRotateConfig {
intPtr := func(a int) *int {
return &a
}
return LogRotateConfig{
MaxSizeMb: intPtr(100),
MaxFiles: 5,
CompressionEnabled: true,
FilePattern: "",
}
}