From 06a956e3e557c46183733bcf7a0dc90226cc8300 Mon Sep 17 00:00:00 2001 From: Tomasz Zaremba Date: Thu, 25 Aug 2022 14:14:38 +0200 Subject: [PATCH] fix: Add -i flag to ignore not known sysctl properties on macOS --- .../dataProvider_darwin.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/agent/plugins/inventory/gatherers/instancedetailedinformation/dataProvider_darwin.go b/agent/plugins/inventory/gatherers/instancedetailedinformation/dataProvider_darwin.go index 2fd3cbff7..5fcb47859 100644 --- a/agent/plugins/inventory/gatherers/instancedetailedinformation/dataProvider_darwin.go +++ b/agent/plugins/inventory/gatherers/instancedetailedinformation/dataProvider_darwin.go @@ -27,13 +27,14 @@ import ( ) const ( - sysctlCmd = "sysctl" - cpuModelNameKey = "machdep.cpu.brand_string" - cpuCoreKey = "hw.physicalcpu" - cpusKey = "hw.logicalcpu" - cpuFreqKey = "hw.cpufrequency" - threadTypeKey = "hw.cputhreadtype" - kernelVersionKey = "kern.osrelease" + sysctlCmd = "sysctl" + sysctlCmdIgnoreUnknownFlag = "-i" + cpuModelNameKey = "machdep.cpu.brand_string" + cpuCoreKey = "hw.physicalcpu" + cpusKey = "hw.logicalcpu" + cpuFreqKey = "hw.cpufrequency" + threadTypeKey = "hw.cputhreadtype" + kernelVersionKey = "kern.osrelease" ) // cmdExecutor decouples exec.Command for easy testability @@ -50,7 +51,7 @@ func collectPlatformDependentInstanceData(context context.T) (appData []model.In var output []byte var err error cmd := sysctlCmd - args := []string{cpuModelNameKey, cpuCoreKey, cpusKey, cpuFreqKey, threadTypeKey} + args := []string{sysctlCmdIgnoreUnknownFlag, cpuModelNameKey, cpuCoreKey, cpusKey, cpuFreqKey, threadTypeKey} log.Infof("Executing command: %v", cmd) if output, err = cmdExecutor(cmd, args...); err != nil {