Skip to content

Commit 06a956e

Browse files
fix: Add -i flag to ignore not known sysctl properties on macOS
1 parent 5e40f04 commit 06a956e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

agent/plugins/inventory/gatherers/instancedetailedinformation/dataProvider_darwin.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@ import (
2727
)
2828

2929
const (
30-
sysctlCmd = "sysctl"
31-
cpuModelNameKey = "machdep.cpu.brand_string"
32-
cpuCoreKey = "hw.physicalcpu"
33-
cpusKey = "hw.logicalcpu"
34-
cpuFreqKey = "hw.cpufrequency"
35-
threadTypeKey = "hw.cputhreadtype"
36-
kernelVersionKey = "kern.osrelease"
30+
sysctlCmd = "sysctl"
31+
sysctlCmdIgnoreUnknownFlag = "-i"
32+
cpuModelNameKey = "machdep.cpu.brand_string"
33+
cpuCoreKey = "hw.physicalcpu"
34+
cpusKey = "hw.logicalcpu"
35+
cpuFreqKey = "hw.cpufrequency"
36+
threadTypeKey = "hw.cputhreadtype"
37+
kernelVersionKey = "kern.osrelease"
3738
)
3839

3940
// cmdExecutor decouples exec.Command for easy testability
@@ -50,7 +51,7 @@ func collectPlatformDependentInstanceData(context context.T) (appData []model.In
5051
var output []byte
5152
var err error
5253
cmd := sysctlCmd
53-
args := []string{cpuModelNameKey, cpuCoreKey, cpusKey, cpuFreqKey, threadTypeKey}
54+
args := []string{sysctlCmdIgnoreUnknownFlag, cpuModelNameKey, cpuCoreKey, cpusKey, cpuFreqKey, threadTypeKey}
5455

5556
log.Infof("Executing command: %v", cmd)
5657
if output, err = cmdExecutor(cmd, args...); err != nil {

0 commit comments

Comments
 (0)